problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
angular 2 animation vs css animation - when to use what? : <p>I'm currently trying out angular2's animation and I was wondering what specific advantage they bring over standard css animations/transitions.</p>
<p>e.g. a typical material designed card and hover effects with the box shadows. Most css frameworks use :hover and css-transitions. Is there a particular advantage in using angular 2 animations?</p>
<p>I read somewhere that some css animation properties don't invoke the GPU as much, hence there's somethings delays and lags. What about angular2 animations?</p>
| 0debug
|
Bolding a specific part of cell : <p>I have a cell that is referenced as <code>="Dealer: " & CustomerName</code>.
CustomerName is a dictionary referenced name. How could I go along of bolding only "Dealer:" and not the Customer name.</p>
<p>Example:</p>
<p><strong>Dealer:</strong> Josh</p>
<p>I have tried</p>
<pre><code>Cells(5, 1).Characters(1, 7).Font.Bold = True
</code></pre>
<p>But it only seems to work on non referenced cells only. How could I get this to work on a referenced cell?</p>
| 0debug
|
static int mkv_write_chapters(AVFormatContext *s)
{
MatroskaMuxContext *mkv = s->priv_data;
AVIOContext *pb = s->pb;
ebml_master chapters, editionentry;
AVRational scale = {1, 1E9};
int i, ret;
if (!s->nb_chapters || mkv->wrote_chapters)
return 0;
ret = mkv_add_seekhead_entry(mkv->main_seekhead, MATROSKA_ID_CHAPTERS, avio_tell(pb));
if (ret < 0) return ret;
chapters = start_ebml_master(pb, MATROSKA_ID_CHAPTERS , 0);
editionentry = start_ebml_master(pb, MATROSKA_ID_EDITIONENTRY, 0);
put_ebml_uint(pb, MATROSKA_ID_EDITIONFLAGDEFAULT, 1);
put_ebml_uint(pb, MATROSKA_ID_EDITIONFLAGHIDDEN , 0);
for (i = 0; i < s->nb_chapters; i++) {
ebml_master chapteratom, chapterdisplay;
AVChapter *c = s->chapters[i];
AVDictionaryEntry *t = NULL;
chapteratom = start_ebml_master(pb, MATROSKA_ID_CHAPTERATOM, 0);
put_ebml_uint(pb, MATROSKA_ID_CHAPTERUID, c->id);
put_ebml_uint(pb, MATROSKA_ID_CHAPTERTIMESTART,
av_rescale_q(c->start, c->time_base, scale));
put_ebml_uint(pb, MATROSKA_ID_CHAPTERTIMEEND,
av_rescale_q(c->end, c->time_base, scale));
put_ebml_uint(pb, MATROSKA_ID_CHAPTERFLAGHIDDEN , 0);
put_ebml_uint(pb, MATROSKA_ID_CHAPTERFLAGENABLED, 1);
if ((t = av_dict_get(c->metadata, "title", NULL, 0))) {
chapterdisplay = start_ebml_master(pb, MATROSKA_ID_CHAPTERDISPLAY, 0);
put_ebml_string(pb, MATROSKA_ID_CHAPSTRING, t->value);
put_ebml_string(pb, MATROSKA_ID_CHAPLANG , "und");
end_ebml_master(pb, chapterdisplay);
}
end_ebml_master(pb, chapteratom);
}
end_ebml_master(pb, editionentry);
end_ebml_master(pb, chapters);
mkv->wrote_chapters = 1;
return 0;
}
| 1threat
|
static void xbr3x(AVFrame *input, AVFrame *output, const uint32_t *r2y)
{
const int nl = output->linesize[0]>>2;
const int nl1 = nl + nl;
uint32_t pprev;
uint32_t pprev2;
int x,y;
for (y = 0; y < input->height; y++) {
uint32_t * E = (uint32_t *)(output->data[0] + y * output->linesize[0] * 3);
uint32_t * sa2 = (uint32_t *)(input->data[0] + y * input->linesize[0] - 8);
uint32_t * sa1 = sa2 - (input->linesize[0]>>2);
uint32_t * sa0 = sa1 - (input->linesize[0]>>2);
uint32_t * sa3 = sa2 + (input->linesize[0]>>2);
uint32_t * sa4 = sa3 + (input->linesize[0]>>2);
if (y <= 1){
sa0 = sa1;
if (y == 0){
sa0 = sa1 = sa2;
}
}
if (y >= input->height - 2){
sa4 = sa3;
if (y == input->height - 1){
sa4 = sa3 = sa2;
}
}
pprev = pprev2 = 2;
for (x = 0; x < input->width; x++){
uint32_t B1 = sa0[2];
uint32_t PB = sa1[2];
uint32_t PE = sa2[2];
uint32_t PH = sa3[2];
uint32_t H5 = sa4[2];
uint32_t A1 = sa0[pprev];
uint32_t PA = sa1[pprev];
uint32_t PD = sa2[pprev];
uint32_t PG = sa3[pprev];
uint32_t G5 = sa4[pprev];
uint32_t A0 = sa1[pprev2];
uint32_t D0 = sa2[pprev2];
uint32_t G0 = sa3[pprev2];
uint32_t C1 = 0;
uint32_t PC = 0;
uint32_t PF = 0;
uint32_t PI = 0;
uint32_t I5 = 0;
uint32_t C4 = 0;
uint32_t F4 = 0;
uint32_t I4 = 0;
if (x >= input->width - 2){
if (x == input->width - 1){
C1 = sa0[2];
PC = sa1[2];
PF = sa2[2];
PI = sa3[2];
I5 = sa4[2];
C4 = sa1[2];
F4 = sa2[2];
I4 = sa3[2];
} else {
C1 = sa0[3];
PC = sa1[3];
PF = sa2[3];
PI = sa3[3];
I5 = sa4[3];
C4 = sa1[3];
F4 = sa2[3];
I4 = sa3[3];
}
} else {
C1 = sa0[3];
PC = sa1[3];
PF = sa2[3];
PI = sa3[3];
I5 = sa4[3];
C4 = sa1[4];
F4 = sa2[4];
I4 = sa3[4];
}
E[0] = E[1] = E[2] = PE;
E[nl] = E[nl+1] = E[nl+2] = PE;
E[nl1] = E[nl1+1] = E[nl1+2] = PE;
FILT3(PE, PI, PH, PF, PG, PC, PD, PB, PA, G5, C4, G0, D0, C1, B1, F4, I4, H5, I5, A0, A1, 0, 1, 2, nl, nl+1, nl+2, nl1, nl1+1, nl1+2);
FILT3(PE, PC, PF, PB, PI, PA, PH, PD, PG, I4, A1, I5, H5, A0, D0, B1, C1, F4, C4, G5, G0, nl1, nl, 0, nl1+1, nl+1, 1, nl1+2, nl+2, 2);
FILT3(PE, PA, PB, PD, PC, PG, PF, PH, PI, C1, G0, C4, F4, G5, H5, D0, A0, B1, A1, I4, I5, nl1+2, nl1+1, nl1, nl+2, nl+1, nl, 2, 1, 0);
FILT3(PE, PG, PD, PH, PA, PI, PB, PF, PC, A0, I5, A1, B1, I4, F4, H5, G5, D0, G0, C1, C4, 2, nl+2, nl1+2, 1, nl+1, nl1+1, 0, nl, nl1);
sa0 += 1;
sa1 += 1;
sa2 += 1;
sa3 += 1;
sa4 += 1;
E += 3;
if (pprev2){
pprev2--;
pprev = 1;
}
}
}
}
| 1threat
|
Convert YYYY-MM-DD HH:MM:SS to YYYY-MM-DD python : <p>I'm trying to convert </p>
<pre><code>YYYY-MM-DD HH_MM_SS
</code></pre>
<p>to </p>
<pre><code>YYYY-MM-DD
</code></pre>
<p>example:</p>
<pre><code>from datetime import datetime, timedelta
from dateutil.relativedelta import relativedelta
i=0
var="2016-05-03"
while i < 5
new_date = datetime.strptime(var, "%Y-%m-%d") + relativedelta(days=i)
i=i+1
print(new_date)
</code></pre>
<p>in this example I would like to convert new_date to string YYYY-MM-DD. I have tried many option, none of them worked...</p>
<p>I thought it will be quite easy but it is not, how to handle with that ? </p>
| 0debug
|
Not Set Wallpaper in My Home Scrren Android....Can You Give Good Suggestion...? : //It's my function
//private int mW = 0;private int mH = 0;
//private int[] cW = new int[]{R.drawable.wall01, R.drawable.wall02, R.drawable.wall03, R.drawable.wall04, R.drawable.wall05, R.drawable.wall06, R.drawable.wall07, R.drawable.wall08, R.drawable.wall09, R.drawable.wall10, R.drawable.wall11, R.drawable.wall12, R.drawable.wall13, R.drawable.wall14, R.drawable.wall15};
private void cw() {
try {
WallpaperManager localWallpaperManager = WallpaperManager.getInstance(getApplicationContext());
Display display = getWindowManager().getDefaultDisplay();
Point size = new Point();
try {
if (VERSION.SDK_INT >= 11) {
display.getSize(size);
this.mW = size.x;
this.mH = size.y;
} else {
this.mW = display.getWidth();
this.mH = display.getHeight();
}
} catch (Exception e) {
Toast.makeText(this, "Wallpaper has been set not1.", Toast.LENGTH_SHORT).show();
}
Bitmap localBitmap = Bitmap.createScaledBitmap(BitmapFactory.decodeResource(getResources(), this.cW[this.i]), this.mW, this.mH, true);
localWallpaperManager.setWallpaperOffsetSteps(1.0f, 1.0f);
localWallpaperManager.suggestDesiredDimensions(this.mW, this.mH);
try {
localWallpaperManager.setBitmap(localBitmap);
Toast.makeText(this, "Wallpaper has been set successfully.",0).show();
} catch (IOException e2) {
Toast.makeText(this, "Wallpaper has been set not2.", Toast.LENGTH_SHORT).show();
}
} catch (Exception e3) {
Toast.makeText(this, "Wallpaper has been set not3.", Toast.LENGTH_SHORT).show();
}
}
| 0debug
|
HOW TO ROTATE AN OBJECT IN ONE AXIS BY ROTATING ANOTHER OBJECT : I HAVE A STARING WHEEL THAT I WANT TO ROTATE IN Y AXIS. BY ROTATING THIS WHEEL I WANT TO ROTATE A MIRROR AND THIS MIRROR TO FOLLOW THE ROTATION OF STAIRING WHEEL BUT IN Z AXIS AND NOT IN Y. CAN SOMEONE PLS HELP ME?
I TRIED THIS ONE BUT IT IS ROTATING THE 2 OBJECT IN SAME AXIS
void Update()
{
mirror.transform.localRotation = stairing.transform.localRotation;
}
| 0debug
|
Android password visibility toggle not working with support library 25? : <p>I have implemented a TextInputLayout with a password field in the usual way:</p>
<pre><code><android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/returning_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/prompt_password"
android:inputType="textPassword"
android:maxLines="1"
android:textSize="14sp" />
</android.support.design.widget.TextInputLayout>
</code></pre>
<p>This worked fine when using the Android support library up to version 24.0.2, but after switching to 25.0.1:</p>
<pre><code>compile 'com.android.support:design:25.0.1'
compile 'com.android.support:support-v4:25.0.1'
compile 'com.android.support:appcompat-v7:25.0.1'
compile 'com.android.support:support-vector-drawable:25.0.1'
</code></pre>
<p>I no longer see the password visibility toggle (a.k.a. "eye icon") in the widget. Changing to the latest version 25.1.0 does not fix this problem.</p>
<p>Is there anything that I missed and need to change in combination with the support library 25, or could this be an Android issue?</p>
| 0debug
|
Visual Studio 10 doesn't open my c# file anymore? : <p>I did some c# exercise at school but now these exercise gives me so many errors and warnings, it seems they are all corrupeted or something maybe when I deleted duplicated files with ccleaner I ***ed all up. Now I must recovery those c# exercise!! When I debug vs10 tell me if I "would like to continue and run the last successful build". If I hit yes it runs the exercise It was, so where vs10 took the exercise that worked? Can I get it from this? I must recovery those c# exericse please help me ! If I just copy the code it's a way to handle this but I need the graphic form with all of it's component in their position, does exist a way to copy the graphic form? (sorry my english) I'll posts all the errors it gives to me, but if I can resolve it with just by copy and paste it's ok. Plese help, Thank You!</p>
<p><a href="https://i.stack.imgur.com/7hcm0.png" rel="nofollow noreferrer">VS10 output when I debug c# exercise</a></p>
<p><a href="https://i.stack.imgur.com/0Gjev.png" rel="nofollow noreferrer">Errors and warnings</a></p>
| 0debug
|
Powershell application runs in windows 7 but not windows 10 : I have created an app for back up and restore of computers. I also allows modification of ADObjects through the use of custom Profile.ps1 file. The app runs fine in the ISE with no errors and works properly no errors in Windows 7. However when I try to run it in a newly imaged Windows 10 machine I get "Property Can Not Be Found" errors on all my object propertys. The thing is I can read all the propetys when I fill comboboxes fine. The error only occurs when the form is submitted. I will attach 1 of the forms I am having a problem with. Again it runs fine in Windows 7 But not Windows 10. could this be a problem with Microsoft updates. Also "Yes" I am setting "Set-ExecutionPolicy -Scope Process -ExecutionPolicy Unrestricted". Thanks
| 0debug
|
static void pxa2xx_gpio_handler_update(PXA2xxGPIOInfo *s) {
uint32_t level, diff;
int i, bit, line;
for (i = 0; i < PXA2XX_GPIO_BANKS; i ++) {
level = s->olevel[i] & s->dir[i];
for (diff = s->prev_level[i] ^ level; diff; diff ^= 1 << bit) {
bit = ffs(diff) - 1;
line = bit + 32 * i;
qemu_set_irq(s->handler[line], (level >> bit) & 1);
}
s->prev_level[i] = level;
}
}
| 1threat
|
static void handle_child_exit(int sig)
{
pid_t pid;
int status;
while ((pid = waitpid(-1, &status, WNOHANG)) > 0) {
FFServerStream *feed;
for (feed = config.first_feed; feed; feed = feed->next) {
if (feed->pid == pid) {
int uptime = time(0) - feed->pid_start;
feed->pid = 0;
fprintf(stderr, "%s: Pid %d exited with status %d after %d seconds\n", feed->filename, pid, status, uptime);
if (uptime < 30)
feed->child_argv = 0;
}
}
}
need_to_start_children = 1;
}
| 1threat
|
Swift, print issue when use ? and ! variables : <p>I got access error('fatal error: unexpectedly found nil while unwrapping an Optional value') when print variable p02. According to the error message, I still cannot understand the reason.</p>
<pre><code>var p02:Person! = nil
var p03:Person? = nil
if (p02==nil)
{
print("p02 is nil")
}
if (p03==nil)
{
print("p03 is nil")
}
print(p03)
print(p02)
</code></pre>
<p>Anyone know why,
Thanks</p>
| 0debug
|
Make website remain in desktop view both on mobile view : <p>I want my site to have the exact same desktop view on mobile, any possible solution is okay.To get exactly what I meant, open bithubpay.com on your mobile and desktop, they both got the same view.
I will tag many options because I don't know where the solution will come from</p>
| 0debug
|
Error occurred while installing mini_racer (0.2.0) : <p>I am using mac 10.14. I have some problem with mini_racer gem. After run bundle install the below error occurs. I don't know how can I solve this.</p>
<p><strong>Error</strong> </p>
<pre><code>Installing mini_racer 0.2.0 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory:
/Users/vipinkumar/.rvm/gems/ruby-2.5.1@ry_rails5/gems/mini_racer-0.2.0/ext/mini_racer_extension
/Users/vipinkumar/.rvm/rubies/ruby-2.5.1/bin/ruby -r
./siteconf20180911-791-fpmt3t.rb extconf.rb
checking for -lpthread... yes
checking for -lobjc... yes
creating Makefile
current directory:
/Users/vipinkumar/.rvm/gems/ruby-2.5.1@ry_rails5/gems/mini_racer-0.2.0/ext/mini_racer_extension
make "DESTDIR=" clean
current directory:
/Users/vipinkumar/.rvm/gems/ruby-2.5.1@ry_rails5/gems/mini_racer-0.2.0/ext/mini_racer_extension
make "DESTDIR="
compiling mini_racer_extension.cc
clang: warning: argument unused during compilation: '-rdynamic'
[-Wunused-command-line-argument]
In file included from mini_racer_extension.cc:2:
In file included from
/Users/vipinkumar/.rvm/rubies/ruby-2.5.1/include/ruby-2.5.0/ruby.h:33:
In file included from
/Users/vipinkumar/.rvm/rubies/ruby-2.5.1/include/ruby-2.5.0/ruby/ruby.h:2040:
/Users/vipinkumar/.rvm/rubies/ruby-2.5.1/include/ruby-2.5.0/ruby/intern.h:47:19:
warning: 'register' storage class specifier is deprecated and incompatible with
C++17 [-Wdeprecated-register]
void rb_mem_clear(register VALUE*, register long);
^~~~~~~~~
/Users/vipinkumar/.rvm/rubies/ruby-2.5.1/include/ruby-2.5.0/ruby/intern.h:47:36:
warning: 'register' storage class specifier is deprecated and incompatible with
C++17 [-Wdeprecated-register]
void rb_mem_clear(register VALUE*, register long);
^~~~~~~~~
2 warnings generated.
linking shared-object mini_racer_extension.bundle
clang: warning: libstdc++ is deprecated; move to libc++ [-Wdeprecated]
ld: library not found for -lstdc++
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [mini_racer_extension.bundle] Error 1
make failed, exit code 2
Gem files will remain installed in
/Users/vipinkumar/.rvm/gems/ruby-2.5.1@ry_rails5/gems/mini_racer-0.2.0 for
inspection.
Results logged to
/Users/vipinkumar/.rvm/gems/ruby-2.5.1@ry_rails5/extensions/x86_64-darwin-18/2.5.0/mini_racer-0.2.0/gem_make.out
An error occurred while installing mini_racer (0.2.0), and Bundler
cannot continue.
Make sure that `gem install mini_racer -v '0.2.0' --source
'https://rubygems.org/'` succeeds before bundling.
In Gemfile:
mini_racer
</code></pre>
<p>Ruby version 2.5.0 or 2.5.1 and rails 5.0</p>
<p><strong>GemFile</strong> </p>
<pre><code>gem 'mini_racer', platforms: :ruby
</code></pre>
| 0debug
|
static void isabus_fdc_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
dc->realize = isabus_fdc_realize;
dc->fw_name = "fdc";
dc->no_user = 1;
dc->reset = fdctrl_external_reset_isa;
dc->vmsd = &vmstate_isa_fdc;
dc->props = isa_fdc_properties;
set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
}
| 1threat
|
static int tm2_read_deltas(TM2Context *ctx, int stream_id)
{
int d, mb;
int i, v;
d = get_bits(&ctx->gb, 9);
mb = get_bits(&ctx->gb, 5);
av_assert2(mb < 32);
if ((d < 1) || (d > TM2_DELTAS) || (mb < 1)) {
av_log(ctx->avctx, AV_LOG_ERROR, "Incorrect delta table: %i deltas x %i bits\n", d, mb);
return AVERROR_INVALIDDATA;
}
for (i = 0; i < d; i++) {
v = get_bits_long(&ctx->gb, mb);
if (v & (1 << (mb - 1)))
ctx->deltas[stream_id][i] = v - (1 << mb);
else
ctx->deltas[stream_id][i] = v;
}
for (; i < TM2_DELTAS; i++)
ctx->deltas[stream_id][i] = 0;
return 0;
}
| 1threat
|
def is_Word_Present(sentence,word):
s = sentence.split(" ")
for i in s:
if (i == word):
return True
return False
| 0debug
|
Laravel 5.6 Upgrade caused Logging to break : <p>Heey!</p>
<p>So I've recently been given the task to take a Laravel 5.2 up to 5.6. It seemed to be fine...until I tried to do a <code>\Log::info()</code>. Every time I run that, I get a big error, but at the end, it still prints to the log. I saw the 5.6 documentation on creating the <code>config/logger.php</code>. I took a fresh copy of it from github. The only thing I did after that was set an env variable for the <code>LOG_CHANNEL</code> to be single. Here's the error I get: </p>
<blockquote>
<p>[2018-03-02 08:28:59] laravel.EMERGENCY: Unable to create configured logger. Using emergency logger. {"exception":"[object] (InvalidArgumentException(code: 0): Log [] is not defined. at I:\xampp\htdocs\mtm\vendor\laravel\framework\src\Illuminate\Log\LogManager.php:181)
[ ....</p>
</blockquote>
<p>I did a file comparison between Laravel 5.2 and 5.6. I'm not seeing anything that jumps out that would break the Logging functionality. </p>
<p>Has anyone run into this with a Laravel upgrade?</p>
| 0debug
|
Unreachable code? user image upload : <p>Eclipse keeps showing me the syntax error to insert '}' to complete Classbody at the dne of my code, but when i do so, it shows a different error that the last part of the code is unreachable? What am i doing wrong?</p>
<p>My code: </p>
<pre><code> public class GetImage extends Activity {
private static final int MyImage =1;
ImageView iv;
@Override
protected void onCreate(Bundle savedInsatnceState){
super.onCreate(savedInsatnceState);
setContentView(R.layout.diary_edit);
iv=(ImageView)findViewById(R.id.imageView1);
}
public void btnClick(View v){
Intent int3 = new Intent(Intent.ACTION_PICK,android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(int3,MyImage);
}
@Override
protected void onActivityResult (int requestCode , int resultCode , Intent data){
super.onActivityResult(requestCode , resultCode , data);
switch (requestCode){
case MyImage :
if(resultCode == RESULT_OK){
Uri uri=data.getData();
String[]projection ={MediaStore.Images.Media.DATA};
Cursor cursor = getContentResolver ().query(uri,projection , null,null,null);
cursor.moveToFirst();
int columnIndex=cursor.getColumnIndex(projection[0]);
String filePath=cursor.getString(columnIndex);
cursor.close();
Bitmap yourSelectedImage=BitmapFactory.decodeFile(filePath);
Drawable d=new BitmapDrawable(yourSelectedImage);
iv.setBackground(d);
}
break;
ault:
break;
}
}
</code></pre>
| 0debug
|
static uint64_t omap_dpll_read(void *opaque, target_phys_addr_t addr,
unsigned size)
{
struct dpll_ctl_s *s = (struct dpll_ctl_s *) opaque;
if (size != 2) {
return omap_badwidth_read16(opaque, addr);
}
if (addr == 0x00)
return s->mode;
OMAP_BAD_REG(addr);
return 0;
}
| 1threat
|
SHA1 Key for DEBUG & RELEASE ANDROID STUDIO MAC : <p>How do I get my SHA1 Keys for debug and release using android studio on a mac?
(These are required for Google API Keys)</p>
| 0debug
|
angular 5 matsnackbar change action button color : <p>I'm using MatSnackBar for my angular 5 project, and I cannot seem to change the color of the 'action' button. </p>
<p>I've injected the snack bar to my HttpInterceptor:</p>
<pre><code> this.snackBar.open('Invalid Login', 'Ok', {
duration: 2000,
panelClass: ['my-snack-bar']
});
</code></pre>
<p>my css:</p>
<pre><code> .my-snack-bar {
background-color: #E8EAF6;
color: #3D5AFE;
}
</code></pre>
<p>How can I change the 'Ok' action button color?</p>
| 0debug
|
If/while statement doesn't execute (java) : <p>I made a <code>public int</code> so that it will return a number different from a number of other integers. It should've returned 9, but, it just gives me a random number like the if statement isn't even there.</p>
<p>Here's the code</p>
<pre><code>import java.util.*;
static int sum1;
static int sum2 = 1;
static int sum3 = 2;
static int num1 = 3;
static int num2 = 4;
static int num3 = 5;
static int dum1 = 6;
static int dum2 = 7;
static int dum3 = 8;
public static int getNumbers()
{
int holder;
boolean numFound = false;
holder = 1 + (int) (Math.random() * 9);
if (holder == 0) while(numFound = false)
{
holder = 1;
if (holder!=sum1 && holder!=sum2 && holder!=sum3 && holder!=num1 && holder!=num2 && holder!=num3 && holder!=dum1 && holder!=dum2 && holder!=dum3)
{
numFound = true;
}
} else {
if (holder!=sum1 && holder!=sum2 && holder!=sum3 && holder!=num1 && holder!=num2 && holder!=num3 && holder!=dum1 && holder!=dum2 && holder!=dum3)
{
numFound = true;
}
}
return holder;
}
public static void main(String[] args) throws InterruptedException {
sum1 = getNumbers();
System.out.println(sum1);
}
</code></pre>
<p>What's happening and what can I do to fix it?</p>
| 0debug
|
What does the anonymous function give me? : <p>I have in tutorial:</p>
<pre><code>public function execute(BaseRequest $request)
{
$operation = function() use($request) {
return $this->service->execute($request);
};
return $this->session->executeAtomically(
$operation->bindTo($this)
);
}
</code></pre>
<p>What does the anonymous function give me?</p>
<p>Why can't I just do:</p>
<pre><code>public function execute(BaseRequest $request)
{
$operation = $this->service->execute($request);
return $this->session->executeAtomically(
$operation->bindTo($this)
);
}
</code></pre>
<p>?</p>
| 0debug
|
static CharDriverState *qemu_chr_open_tcp(const char *host_str,
int is_telnet,
int is_unix)
{
CharDriverState *chr = NULL;
TCPCharDriver *s = NULL;
int fd = -1, ret, err, val;
int is_listen = 0;
int is_waitconnect = 1;
int do_nodelay = 0;
const char *ptr;
struct sockaddr_in saddr;
#ifndef _WIN32
struct sockaddr_un uaddr;
#endif
struct sockaddr *addr;
socklen_t addrlen;
#ifndef _WIN32
if (is_unix) {
addr = (struct sockaddr *)&uaddr;
addrlen = sizeof(uaddr);
if (parse_unix_path(&uaddr, host_str) < 0)
goto fail;
} else
#endif
{
addr = (struct sockaddr *)&saddr;
addrlen = sizeof(saddr);
if (parse_host_port(&saddr, host_str) < 0)
goto fail;
}
ptr = host_str;
while((ptr = strchr(ptr,','))) {
ptr++;
if (!strncmp(ptr,"server",6)) {
is_listen = 1;
} else if (!strncmp(ptr,"nowait",6)) {
is_waitconnect = 0;
} else if (!strncmp(ptr,"nodelay",6)) {
do_nodelay = 1;
} else {
printf("Unknown option: %s\n", ptr);
goto fail;
}
}
if (!is_listen)
is_waitconnect = 0;
chr = qemu_mallocz(sizeof(CharDriverState));
if (!chr)
goto fail;
s = qemu_mallocz(sizeof(TCPCharDriver));
if (!s)
goto fail;
#ifndef _WIN32
if (is_unix)
fd = socket(PF_UNIX, SOCK_STREAM, 0);
else
#endif
fd = socket(PF_INET, SOCK_STREAM, 0);
if (fd < 0)
goto fail;
if (!is_waitconnect)
socket_set_nonblock(fd);
s->connected = 0;
s->fd = -1;
s->listen_fd = -1;
s->is_unix = is_unix;
s->do_nodelay = do_nodelay && !is_unix;
chr->opaque = s;
chr->chr_write = tcp_chr_write;
chr->chr_close = tcp_chr_close;
if (is_listen) {
#ifndef _WIN32
if (is_unix) {
char path[109];
pstrcpy(path, sizeof(path), uaddr.sun_path);
unlink(path);
} else
#endif
{
val = 1;
setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (const char *)&val, sizeof(val));
}
ret = bind(fd, addr, addrlen);
if (ret < 0)
goto fail;
ret = listen(fd, 0);
if (ret < 0)
goto fail;
s->listen_fd = fd;
qemu_set_fd_handler(s->listen_fd, tcp_chr_accept, NULL, chr);
if (is_telnet)
s->do_telnetopt = 1;
} else {
for(;;) {
ret = connect(fd, addr, addrlen);
if (ret < 0) {
err = socket_error();
if (err == EINTR || err == EWOULDBLOCK) {
} else if (err == EINPROGRESS) {
break;
#ifdef _WIN32
} else if (err == WSAEALREADY) {
break;
#endif
} else {
goto fail;
}
} else {
s->connected = 1;
break;
}
}
s->fd = fd;
socket_set_nodelay(fd);
if (s->connected)
tcp_chr_connect(chr);
else
qemu_set_fd_handler(s->fd, NULL, tcp_chr_connect, chr);
}
if (is_listen && is_waitconnect) {
printf("QEMU waiting for connection on: %s\n", host_str);
tcp_chr_accept(chr);
socket_set_nonblock(s->listen_fd);
}
return chr;
fail:
if (fd >= 0)
closesocket(fd);
qemu_free(s);
qemu_free(chr);
return NULL;
}
| 1threat
|
static gboolean pty_chr_read(GIOChannel *chan, GIOCondition cond, void *opaque)
{
CharDriverState *chr = opaque;
PtyCharDriver *s = chr->opaque;
gsize size, len;
uint8_t buf[READ_BUF_LEN];
GIOStatus status;
len = sizeof(buf);
if (len > s->read_bytes)
len = s->read_bytes;
if (len == 0)
return FALSE;
status = g_io_channel_read_chars(s->fd, (gchar *)buf, len, &size, NULL);
if (status != G_IO_STATUS_NORMAL) {
pty_chr_state(chr, 0);
return FALSE;
} else {
pty_chr_state(chr, 1);
qemu_chr_be_write(chr, buf, size);
}
return TRUE;
}
| 1threat
|
static int scsi_hd_initfn(SCSIDevice *dev)
{
SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, dev);
s->qdev.blocksize = s->qdev.conf.logical_block_size;
s->qdev.type = TYPE_DISK;
if (!s->product) {
s->product = g_strdup("QEMU HARDDISK");
}
return scsi_initfn(&s->qdev);
}
| 1threat
|
Selenium Win10 Ie11 There are no more files? : I am using VS2017 on a Win10 (17134.471) machine and I just installed Selenium. I can get Chrome, Firefox, Edge to work but not IE11 (11.471.171340). I believe that I have done all the other suggested updates but continue to get "There are no more files".
Test Name: IeMethod
Test FullName: utLearn2018.FirstTestClass.IeMethod
Test Source: C:\Users\stephan\Documents\Visual Studio 2017\Projects\utLearn2018\utLearn2018\FirstTestClass.cs : line 44
Test Outcome: Failed
Test Duration: 0:00:22.3336919
Result StackTrace:
at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
at OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilities desiredCapabilities)
at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities)
at OpenQA.Selenium.IE.InternetExplorerDriver..ctor(InternetExplorerDriverService service, InternetExplorerOptions options)
at OpenQA.Selenium.IE.InternetExplorerDriver..ctor()
at utLearn2018.FirstTestClass.IeMethod() in C:\Users\stephan\Documents\Visual Studio 2017\Projects\utLearn2018\utLearn2018\FirstTestClass.cs:line 53
Result Message:
Test method utLearn2018.FirstTestClass.IeMethod threw exception:
System.InvalidOperationException: Unexpected error launching Internet Explorer. IELaunchURL() returned HRESULT 80070012 ('There are no more files.') for URL 'http://localhost:50326/' (SessionNotCreated)
My code is as follows
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.Edge;
using OpenQA.Selenium.IE;
[TestMethod]
public void IeMethod()
{
InternetExplorerOptions options = new InternetExplorerOptions
{
IntroduceInstabilityByIgnoringProtectedModeSettings = true,
EnableNativeEvents = false,
EnsureCleanSession = true
};
IWebDriver driver = new InternetExplorerDriver();
driver.Navigate().GoToUrl("http://www.google.com");
driver.Manage().Window.Maximize();
driver.Close();
driver.Quit();
}
| 0debug
|
How to print variables with #define like #define STR(M) = value of M : <pre><code>#include <stdio.h>
#define STR /*~~Complete this line~~*/
/* such that the output of the code is
M = 10
N = 5
*/
#define N 5
#define M 10
int main() {
printf(STR(M));
printf("\n");
printf(STR(N));
return 0;
}
</code></pre>
<p>We have to print M = 10 and N = 5 to the console.
I don't know how do we do that. Please help me. The question is well explained in the code itself.</p>
| 0debug
|
Using dynamic_cast in c++ : <p>I have 4 classes in c++ . Animal is the super class were Snake and Tiger inherit from Animal but also inherit from Dangerous Animal . I have implemented a function to check if Snake or tiger is an instance of DangerousAnimal . However I am finding problems in implemting it in c++</p>
<p>my code is :</p>
<pre><code>bool Vet::examine (Animal *someAnimal){
if(DangerousAnimal* s = dynamic_cast<DangerousAnimal*>(Animal)){
return false;
}else{
return true;
}
}
</code></pre>
<p>The error is </p>
<pre><code>dillu24@dillu24-VirtualBox:~/Desktop/OOP/Lab1$ g++ -std=c++11 -oAnimalWellBeingLauncher AnimalWellBeingLauncher.cpp q1.cpp
q1.cpp: In member function ‘bool Vet::examine(Animal*)’:
q1.cpp:122:64: error: expected primary-expression before ‘)’ token
if(DangerousAnimal* s = dynamic_cast<DangerousAnimal*>(Animal)){
</code></pre>
| 0debug
|
How to split a string by uppercase and lowercase in JavaScript? : <p>Is it possible to split Strings in JavaScript by case such that the following string below (myString) would be converted into the array (myArray) below:</p>
<pre><code>var myString = "HOWtoDOthis";
var myArray = ["HOW", "to", "DO", "this"];
</code></pre>
<p>I have tried the regex below, but it only splits for camelCase:</p>
<pre><code>.match(/[A-Z]*[^A-Z]+/g);
</code></pre>
| 0debug
|
return ture if first string contain all letters of second string : <p>I have to check if one string contain all letters of other string .
example : string 1 = "mary"; string 2 = "aarmy";
should return true;
I tried to indexOf method but this will check only entire string in same
order. please suggest me any solution.</p>
| 0debug
|
static int sub2video_prepare(InputStream *ist, InputFilter *ifilter)
{
AVFormatContext *avf = input_files[ist->file_index]->ctx;
int i, w, h;
w = ifilter->width;
h = ifilter->height;
if (!(w && h)) {
for (i = 0; i < avf->nb_streams; i++) {
if (avf->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
w = FFMAX(w, avf->streams[i]->codecpar->width);
h = FFMAX(h, avf->streams[i]->codecpar->height);
}
}
if (!(w && h)) {
w = FFMAX(w, 720);
h = FFMAX(h, 576);
}
av_log(avf, AV_LOG_INFO, "sub2video: using %dx%d canvas\n", w, h);
}
ist->sub2video.w = ist->resample_width = w;
ist->sub2video.h = ist->resample_height = h;
ist->resample_pix_fmt = ifilter->format = AV_PIX_FMT_RGB32;
ist->sub2video.frame = av_frame_alloc();
if (!ist->sub2video.frame)
return AVERROR(ENOMEM);
ist->sub2video.last_pts = INT64_MIN;
return 0;
}
| 1threat
|
Puppeteer unable to run on heroku : <p>I deployed an app on heroku, and i added the puppeteer Heroku buildpack.</p>
<p>After a succesful redeployment, i try to run it and it fails. Using <code>heroku logs -t</code>, i get this error message:</p>
<pre><code>2018-09-07T13:16:10.870497+00:00 app[web.1]: Error: Failed to launch chrome!
2018-09-07T13:16:10.870512+00:00 app[web.1]: [0907/131610.045486:FATAL:zygote_ho
st_impl_linux.cc(116)] No usable sandbox! Update your kernel or see https://chro
mium.googlesource.com/chromium/src/+/master/docs/linux_suid_sandbox_development.
md for more information on developing with the SUID sandbox. If you want to live
dangerously and need an immediate workaround, you can try using --no-sandbox.
</code></pre>
| 0debug
|
ImageView - null object reference : <p>I'm building a <code>reyclerView</code> that loads images into the titleChild. I uploaded <code>test_image</code> into res/drawable but I keep seeing null object reference at</p>
<pre><code>titleChildViewHolder.option1.setImageResource(R.drawable.test_image);
titleChildViewHolder.option2.setImageResource(R.drawable.test_image);
</code></pre>
<p><a href="https://i.stack.imgur.com/w54gJ.jpg" rel="nofollow noreferrer">enter image description here</a></p>
| 0debug
|
An assembly specified in the application dependencies manifest was not found: : <p>I developed application in asp.net-core 2.0 preview1.
I developed on windows with Visual Studio 2017.</p>
<p>Now I want to deploy it to Linux server using Docker.</p>
<p>I created Docker file:</p>
<pre><code>FROM microsoft/aspnetcore:2.0
ARG source
WORKDIR /app
EXPOSE 44305
COPY ${source:-obj/Docker/publish} .
ENTRYPOINT ["dotnet", "Aplication.dll"]
</code></pre>
<p>After that running commands:</p>
<pre><code>dotnet build -o obj/Docker/publish -c Release
dotnet publish -o obj/Docker/publish -c Release
docker build -t testapi-api .
docker run -p 44305:80 --name api testapi-api
</code></pre>
<p>Afer the last command <code>run</code> I am getting next error:</p>
<pre><code>An assembly specified in the application dependencies manifest (Aplication.deps.json) was not found:
package: 'Microsoft.AspNetCore.Antiforgery', version: '2.0.0-preview1-final'
path: 'lib/netcoreapp2.0/Microsoft.AspNetCore.Antiforgery.dll'
This assembly was expected to be in the local runtime store as the application was published using the following target manifest files:
manifest.win7-x64.xml;manifest.win7-x86.xml;manifest.osx-x64.xml;manifest.linux-x64.xml
</code></pre>
<p>I am new with asp.net-core and especially with Docker. So any help with this is great.</p>
| 0debug
|
static void sparc_cpu_class_init(ObjectClass *oc, void *data)
{
SPARCCPUClass *scc = SPARC_CPU_CLASS(oc);
CPUClass *cc = CPU_CLASS(oc);
DeviceClass *dc = DEVICE_CLASS(oc);
scc->parent_realize = dc->realize;
dc->realize = sparc_cpu_realizefn;
scc->parent_reset = cc->reset;
cc->reset = sparc_cpu_reset;
cc->has_work = sparc_cpu_has_work;
cc->do_interrupt = sparc_cpu_do_interrupt;
cc->cpu_exec_interrupt = sparc_cpu_exec_interrupt;
cc->dump_state = sparc_cpu_dump_state;
#if !defined(TARGET_SPARC64) && !defined(CONFIG_USER_ONLY)
cc->memory_rw_debug = sparc_cpu_memory_rw_debug;
#endif
cc->set_pc = sparc_cpu_set_pc;
cc->synchronize_from_tb = sparc_cpu_synchronize_from_tb;
cc->gdb_read_register = sparc_cpu_gdb_read_register;
cc->gdb_write_register = sparc_cpu_gdb_write_register;
#ifdef CONFIG_USER_ONLY
cc->handle_mmu_fault = sparc_cpu_handle_mmu_fault;
#else
cc->do_unassigned_access = sparc_cpu_unassigned_access;
cc->do_unaligned_access = sparc_cpu_do_unaligned_access;
cc->get_phys_page_debug = sparc_cpu_get_phys_page_debug;
cc->vmsd = &vmstate_sparc_cpu;
#endif
cc->disas_set_info = cpu_sparc_disas_set_info;
#if defined(TARGET_SPARC64) && !defined(TARGET_ABI32)
cc->gdb_num_core_regs = 86;
#else
cc->gdb_num_core_regs = 72;
#endif
dc->cannot_destroy_with_object_finalize_yet = true;
}
| 1threat
|
How i can access to JSON data? : <p>i have created a dynamic array and then, i convert it to json object. The code is the follows:</p>
<pre><code>$array_D1[]="";
$array_D2[]="";
$array_to_send[]="";
$array_D1[$CapaEnviar][] = $fila['test_name'];
$array_D2[]=$seleccio_content;
$array_D2[]=$id_capa;
$array_D2[]=$pagina;
$array_D2[]=$idtest;
$array_D2[]=$valor_org;
$array_D2[]=$valor_eval;
$array_D2[]=$valor_test;
$array_to_send=array('data1' => $array_D1, 'data2' => $array_D2);
echo json_encode($array_to_send,true);
</code></pre>
<p>This code is a AJAX response for an AJAX request. I don't know how i can access JSON data from jquery.</p>
<p>i need to acces the values from "data1" and "data2"</p>
| 0debug
|
Android Best Practice for network operation at regular interval : I am making an application which contains performing network calls to look for updates. Can anyone help with some best practices to perform this task. I can make a service to run on background and perform network operation using Handler at regular intervals but this would consume a lot of data and battery. Is there any other way to do this? Thanks in advance.
| 0debug
|
static members vs module for type in F#? : <p>Suppose I have a type like this: </p>
<pre><code>type Season =
| Spring
| Summer
| Autumn
| Winter
</code></pre>
<p>I want to have a function <code>next</code> that returns the next season: </p>
<pre><code>let next s =
match s with
| Spring -> Summer
| Summer -> Autumn
| Autumn -> Winter
| Winter -> Spring
</code></pre>
<p>There are two places I can put this function. </p>
<p>In a named module: </p>
<pre><code>module Season =
let next s =
match s with
| Spring -> Summer
| Summer -> Autumn
| Autumn -> Winter
| Winter -> Spring
</code></pre>
<p>Or as a static member on the type: </p>
<pre><code>type Season =
| Spring
| Summer
| Autumn
| Winter
with
static member next s =
match s with
| Spring -> Summer
| Summer -> Autumn
| Autumn -> Winter
| Winter -> Spring
</code></pre>
<p>What are the reasons to favour each approach? </p>
| 0debug
|
static int es1370_initfn (PCIDevice *dev)
{
ES1370State *s = DO_UPCAST (ES1370State, dev, dev);
uint8_t *c = s->dev.config;
pci_config_set_vendor_id (c, PCI_VENDOR_ID_ENSONIQ);
pci_config_set_device_id (c, PCI_DEVICE_ID_ENSONIQ_ES1370);
c[PCI_STATUS + 1] = PCI_STATUS_DEVSEL_SLOW >> 8;
pci_config_set_class (c, PCI_CLASS_MULTIMEDIA_AUDIO);
#if 1
c[PCI_SUBSYSTEM_VENDOR_ID] = 0x42;
c[PCI_SUBSYSTEM_VENDOR_ID + 1] = 0x49;
c[PCI_SUBSYSTEM_ID] = 0x4c;
c[PCI_SUBSYSTEM_ID + 1] = 0x4c;
#else
c[PCI_SUBSYSTEM_VENDOR_ID] = 0x74;
c[PCI_SUBSYSTEM_VENDOR_ID + 1] = 0x12;
c[PCI_SUBSYSTEM_ID] = 0x71;
c[PCI_SUBSYSTEM_ID + 1] = 0x13;
c[PCI_CAPABILITY_LIST] = 0xdc;
c[PCI_INTERRUPT_LINE] = 10;
c[0xdc] = 0x00;
#endif
c[PCI_INTERRUPT_PIN] = 1;
c[PCI_MIN_GNT] = 0x0c;
c[PCI_MAX_LAT] = 0x80;
pci_register_bar (&s->dev, 0, 256, PCI_BASE_ADDRESS_SPACE_IO, es1370_map);
qemu_register_reset (es1370_on_reset, s);
AUD_register_card ("es1370", &s->card);
es1370_reset (s);
return 0;
}
| 1threat
|
How to add mixins to ES6 javascript classes? : <p>In an ES6 class with some instance variables and methods, how can you add a mixin to it? I've given an example below, though I don't know if the syntax for the mixin object is correct.</p>
<pre><code>class Test {
constructor() {
this.var1 = 'var1'
}
method1() {
console.log(this.var1)
}
test() {
this.method2()
}
}
var mixin = {
var2: 'var2',
method2: {
console.log(this.var2)
}
}
</code></pre>
<p>If I run <code>(new Test()).test()</code>, it will fail because there's no <code>method2</code> on the class, as it's in the mixin, that's why I need to add the mixin variables and methods to the class.</p>
<p>I see there's a lodash mixin function <a href="https://lodash.com/docs/4.17.4#mixin" rel="noreferrer">https://lodash.com/docs/4.17.4#mixin</a>, but I don't know how I could use it with ES6 classes. I'm fine with using lodash for the solution, or even plain JS with no libraries to provide the mixin functionality.</p>
| 0debug
|
UISearchBar increases navigation bar height in iOS 11 : <p>I have my <code>UISearchBar</code> being part of the navigation bar like:</p>
<pre><code> let searchBar = UISearchBar()
//some more configuration to the search bar
.....
navigationItem.titleView = searchBar
</code></pre>
<p>After updating to <code>iOS 11</code> something weird happened to the search bar in my app. On <code>iOS 10</code> and prior I had my navigation bar looking like:</p>
<p><a href="https://i.stack.imgur.com/1VpIT.png" rel="noreferrer"><img src="https://i.stack.imgur.com/1VpIT.png" alt="enter image description here"></a></p>
<p>Now with <code>iOS 11</code> I have: </p>
<p><a href="https://i.stack.imgur.com/GpeXA.png" rel="noreferrer"><img src="https://i.stack.imgur.com/GpeXA.png" alt="enter image description here"></a></p>
<p>As you can see there is difference in the rounding of the two search bars which does not bothers me. The problem is that the search bar increases the height of the navigation bar. So when I go to another controller it looks weird too:</p>
<p><a href="https://i.stack.imgur.com/ec5fQ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ec5fQ.png" alt="enter image description here"></a></p>
<p>In fact that weird black line's height plus the current navigation bar's height is equal to the height of navigation bar shown in the second picture ... </p>
<p>Any ideas how to get rid of the black line and having consistent navigation bar height across all view controllers ? </p>
| 0debug
|
static void do_change(int argc, const char **argv)
{
BlockDriverState *bs;
if (argc != 3) {
help_cmd(argv[0]);
return;
}
bs = bdrv_find(argv[1]);
if (!bs) {
term_printf("device not found\n");
return;
}
if (eject_device(bs, 0) < 0)
return;
bdrv_open(bs, argv[2], 0);
}
| 1threat
|
connection.query('SELECT * FROM users WHERE username = ' + input_string)
| 1threat
|
FacebookSdk.sdkInitialize (Context) is deprecated : <p>I'm using facebook-android-sdk-4.19.0 in Android Studio and I followed the Facebook quick start guide at <a href="https://developers.facebook.com/docs/android/getting-started">https://developers.facebook.com/docs/android/getting-started</a> (Click on the Quick Start button to sign in with your own facebook account). In the guide, it's told to copy&paste the following code in the snippet to track app logs</p>
<pre><code>import com.facebook.FacebookSdk;
import com.facebook.appevents.AppEventsLogger;
public class MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
FacebookSdk.sdkInitialize(getApplicationContext());
AppEventsLogger.activateApp(this);
}
}
</code></pre>
<p>However, when I copy pasted the code in android studio, it appears that all of the FacebookSdk.sdkInitialize() methods are deprecated. The documentation here <a href="https://developers.facebook.com/docs/reference/android/current/class/FacebookSdk/">https://developers.facebook.com/docs/reference/android/current/class/FacebookSdk/</a> tells nothing about what method to use to initialize the sdk instead of sdkInitialize(). What method should I use?</p>
| 0debug
|
Do i have to install DNX on my server to serve asp.net 5 site? : <p>Thats really frustrating how hard is publish a website with asp.net 5. Very bad documentation, and all things said in internet does not work for me. Someone here already made it work? My server has iis 7.5. Do i have to install asp.net 5 on my server? I heard i do not need to install. Please help.</p>
| 0debug
|
Laravel authentication without global scope : <p>In my Laravel app users can disable (not delete) their account to disappear from the website. However, if they try to login again their account should be activated automatically and they should log in successfully.</p>
<p>This is done with "active" column in the users table and a global scope in User model:</p>
<pre><code>protected static function boot() {
parent::boot();
static::addGlobalScope('active', function(Builder $builder) {
$builder->where('active', 1);
});
}
</code></pre>
<p>The problem now is that those inactive accounts can't log in again, since AuthController does not find them (out of scope).</p>
<p>What I need to achieve:</p>
<ol>
<li>Make AuthController ignore global scope "active".</li>
<li>If username and password are correct then change the "active" column value to "1".</li>
</ol>
<p>The idea I have now is to locate the user using withoutGlobalScope, validate the password manually, change column "active" to 1, and then proceed the regular login.</p>
<p>In my AuthController in postLogin method:</p>
<pre><code>$user = User::withoutGlobalScope('active')
->where('username', $request->username)
->first();
if($user != null) {
if (Hash::check($request->username, $user->password))
{
// Set active column to 1
}
}
return $this->login($request);
</code></pre>
<p>So the question is how to make AuthController ignore global scope without altering Laravel main code, so it will remain with update?</p>
<p>Thanks.</p>
| 0debug
|
Flutter - How to blend an image with a gradient colour? : <p>I am attempting to replicate a login screen design my designer did for an app.</p>
<p>The background image uses a blendMode of softLight, the catch is that the colour it blends with is a gradient colour. Secondly there is actually two layers of different gradients (one purple gradient, one blue gradient)</p>
<p><strong>Original Image:</strong></p>
<p><a href="https://i.stack.imgur.com/PQJxo.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/PQJxo.jpg" alt="Original Image"></a></p>
<p><strong>Final Gradient Image</strong></p>
<p><a href="https://i.stack.imgur.com/AHsaL.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/AHsaL.jpg" alt="Final Gradient Image"></a></p>
<p>Now I have tried using colorBlendMode, e.g.</p>
<pre><code>Image.asset(
'assets/pioneer-party.jpg',
fit: BoxFit.cover,
color: Color(0xff0d69ff).withOpacity(1.0),
colorBlendMode: BlendMode.softLight,
),
</code></pre>
<p>The problem is that the color property only takes a single colour.</p>
<p>I then tried BoxDecoration, e.g.</p>
<pre><code>DecoratedBox(
decoration: new BoxDecoration(
color: const Color(0xff7c94b6),
image: new DecorationImage(
fit: BoxFit.cover,
colorFilter: new ColorFilter.mode(Colors.purple.withOpacity(1.0), BlendMode.softLight),
image: new NetworkImage(
'http://www.allwhitebackground.com/images/2/2582-190x190.jpg',
),
),
),
),
</code></pre>
<p>Which still leaves me with the same problem. I then tried stacking each layer individually and then playing around with gradients to make it appear close to the design, e.g.</p>
<pre><code>Image.asset(
'assets/pioneer-party.jpg',
fit: BoxFit.cover,
color: Color(0xff0d69ff).withOpacity(1.0),
colorBlendMode: BlendMode.softLight,
),
DecoratedBox(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: FractionalOffset.topCenter,
end: FractionalOffset.bottomCenter,
colors: [
Color(0xff0d69ff).withOpacity(0.0),
Color(0xff0069ff).withOpacity(0.8),
],
),
),
),
DecoratedBox(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: FractionalOffset.topLeft,
end: FractionalOffset.bottomRight,
colors: [
Color(0xff692eff).withOpacity(0.8),
Color(0xff642cf4).withOpacity(0.8),
Color(0xff602ae9).withOpacity(0.8),
Color(0xff5224c8).withOpacity(0.8),
Color(0xff5e29e5).withOpacity(0.8),
],
stops: [0.0,0.25,0.5,0.75,1.0]
),
),
),
</code></pre>
<p>Which gives me somewhat close to what I want, but not entirely what I need.</p>
<p>Does anyone know of a way to achieve this?</p>
<p>EDIT:</p>
<p>I was also thinking about blending the two images together, but haven't found a way of doing that except using opacity or something. Ideally would like it to be rendered natively rather than using "hacks" to achieve it.</p>
| 0debug
|
Allowing a filename as aController Action : <p>Who can I use one particular filename (id: myfile.gif) as a controller action? What about the route definition.</p>
<p>TIA, /Luis</p>
| 0debug
|
How to keep a JS variable the same even after refreshing page? : <p>I have a speed element in my game however, whenever you fail it refreshes the page.
I do not want people to have to keep resetting their speed every time the page refreshes.
How can I keep the variable the same even after a page refresh?</p>
<p>Thankyou</p>
| 0debug
|
How do i check if userinput in java contains a component in an array? : Am trying to check firstly if user input contains an offensive word listed in my array of offensive word. Then if user input contains such words listed in the array, then print a message saying(Please don't use the <OFFENSIVE WORD>).
| 0debug
|
Java 8 Stream - Map - sort by value : <p>Here is my data set.</p>
<pre><code>public class StudentData {
public static List<Student> getData() {
//student id,name,std, and hobbies
return Arrays.asList(new Student(1, "a1", 1, Arrays.asList("cricket", "football", "basketball")),
new Student(2, "a2", 1, Arrays.asList("chess", "football")),
new Student(3, "a3", 2, Arrays.asList("running")),
new Student(4, "a4", 2, Arrays.asList("throwball", "football")),
new Student(5, "a5", 3, Arrays.asList("cricket", "basketball")),
new Student(6, "a6", 4, Arrays.asList("cricket")), new Student(7, "a7", 5, Arrays.asList("basketball")),
new Student(8, "a8", 6, Arrays.asList("football")),
new Student(9, "a9", 8, Arrays.asList("tennis", "swimming")),
new Student(10, "a10", 8, Arrays.asList("boxing", "running")),
new Student(11, "a11", 9, Arrays.asList("cricket", "football")),
new Student(12, "a12", 11, Arrays.asList("tennis", "shuttle")),
new Student(13, "a13", 12, Arrays.asList("swimming")));
}
}
</code></pre>
<p>From data set , i am finding , how many student based on hobbies and display the value in asc/desc order. For example : cricket ,4 and swimming: 2 and so on.<br>
here is the code for group by hoppies .</p>
<pre><code>Map<String, Integer> collect8 = data.stream()
.flatMap(x -> x.getHobbies().stream().map(y -> new SimpleEntry<>(y, x)))
.collect(Collectors.groupingBy(Entry::getKey, Collectors.mapping(entry -> entry.getValue().getId(),
Collectors.reducing(0, (a, b) -> a + b))));
</code></pre>
<p>output of collect8 :{running=13, swimming=22, shuttle=12, throwball=4, basketball=13, chess=2, cricket=23, boxing=10, football=26, tennis=21}</p>
<p>After that i am doing asc sorting by value .</p>
<pre><code>Map<String, Integer> collect9 =
collect8.entrySet().stream().sorted(Map.Entry.<String, Integer>comparingByValue()).
collect(Collectors.toMap(e->e.getKey(), e->e.getValue()));
System.out.println(collect9);
</code></pre>
<p>output of collect9 : {running=2, swimming=2, shuttle=1, throwball=1, basketball=3, chess=1, cricket=4, boxing=1, football=5, tennis=2}</p>
<p>1.it is not sorted and giving the same result.any idea? <br />
2. i am writing separate code for sorting. is it possble to do in collect8 itself?</p>
| 0debug
|
Why a {get;private set} List's content can be changed? : <p>For example:</p>
<pre><code>class Foo {
List<Object> myList {get;private set;}
}
</code></pre>
<p>then in other script, I can still do this</p>
<pre><code>foo.myList.Add(new Object());
</code></pre>
<p>I know it is just allowed but why? what is the design logic behind this? If you can add/remove stuff from the list then it is really not a <em>private</em> set.</p>
| 0debug
|
static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags,
Error **errp)
{
BDRVRBDState *s = bs->opaque;
char pool[RBD_MAX_POOL_NAME_SIZE];
char snap_buf[RBD_MAX_SNAP_NAME_SIZE];
char conf[RBD_MAX_CONF_SIZE];
char clientname_buf[RBD_MAX_CONF_SIZE];
char *clientname;
QemuOpts *opts;
Error *local_err = NULL;
const char *filename;
int r;
opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort);
qemu_opts_absorb_qdict(opts, options, &local_err);
if (local_err) {
error_propagate(errp, local_err);
qemu_opts_del(opts);
return -EINVAL;
}
filename = qemu_opt_get(opts, "filename");
if (qemu_rbd_parsename(filename, pool, sizeof(pool),
snap_buf, sizeof(snap_buf),
s->name, sizeof(s->name),
conf, sizeof(conf), errp) < 0) {
r = -EINVAL;
goto failed_opts;
}
clientname = qemu_rbd_parse_clientname(conf, clientname_buf);
r = rados_create(&s->cluster, clientname);
if (r < 0) {
error_setg(errp, "error initializing");
goto failed_opts;
}
s->snap = NULL;
if (snap_buf[0] != '\0') {
s->snap = g_strdup(snap_buf);
}
if (flags & BDRV_O_NOCACHE) {
rados_conf_set(s->cluster, "rbd_cache", "false");
} else {
rados_conf_set(s->cluster, "rbd_cache", "true");
}
if (strstr(conf, "conf=") == NULL) {
rados_conf_read_file(s->cluster, NULL);
}
if (conf[0] != '\0') {
r = qemu_rbd_set_conf(s->cluster, conf, errp);
if (r < 0) {
goto failed_shutdown;
}
}
r = rados_connect(s->cluster);
if (r < 0) {
error_setg(errp, "error connecting");
goto failed_shutdown;
}
r = rados_ioctx_create(s->cluster, pool, &s->io_ctx);
if (r < 0) {
error_setg(errp, "error opening pool %s", pool);
goto failed_shutdown;
}
r = rbd_open(s->io_ctx, s->name, &s->image, s->snap);
if (r < 0) {
error_setg(errp, "error reading header from %s", s->name);
goto failed_open;
}
bs->read_only = (s->snap != NULL);
qemu_opts_del(opts);
return 0;
failed_open:
rados_ioctx_destroy(s->io_ctx);
failed_shutdown:
rados_shutdown(s->cluster);
g_free(s->snap);
failed_opts:
qemu_opts_del(opts);
return r;
}
| 1threat
|
BillingClient always returns SERVICE_DISCONNECTED : <p>So I have a billing client which I instantiate with </p>
<pre><code>billingClient = BillingClient.newBuilder(this).setListener(this).build();
</code></pre>
<p>I then call </p>
<pre><code>billingClient.startConnection(new BillingClientStateListener() {
@Override
public void onBillingSetupFinished(int responseCode) {
//TODO: use this for stuff
com.android.billingclient.api.Purchase.PurchasesResult result;
result = billingClient.queryPurchases(BillingClient.SkuType.SUBS);
Timber.d(result.toString());
}
@Override
public void onBillingServiceDisconnected() {
//TODO: use this for stuff
Timber.d("something went wrong ");
}
});
</code></pre>
<p>for whatever reason the breakpoint on the timber line always returns disconnected. can anyone provide insight or an example to how i would do this? </p>
| 0debug
|
Can I throw from class init() in Swift with constant string loaded from file? : <p>I'd like my class <em>init()</em> in Swift to throw an error if something goes wrong with loading a file into a string within the class. Once the file is loaded, the string will not be altered, so I would prefer to use <em>let</em>. This works:</p>
<pre><code>class FileClass {
var text: NSString = ""
init() throws {
do {
text = try NSString( contentsOfFile: "/Users/me/file.txt", encoding: NSUTF8StringEncoding ) }
catch let error as NSError {
text = ""
throw error
}
}
}
</code></pre>
<p>but when I replace</p>
<pre><code>var text: NSString = ""
</code></pre>
<p>with</p>
<pre><code>let text: NSString
</code></pre>
<p>I get an <strong>All stored properties of a class instance must be initialized before throwing from an initializer</strong> error.</p>
<p>I've tried various approaches such as to make <em>text</em> optional</p>
<pre><code>let text: NSString?
</code></pre>
<p>but haven't found any that work. It it possible to have <em>text</em> be loaded from a file, immutable, and for <em>init()</em> to throw an error? Can I have my cake and eat it three?</p>
<p>Many thanks in advance!</p>
| 0debug
|
One-hot encoding in R- creating dataframe column names from variables in a loop : <p>I am using a dataframe called "rawData" which has a column called "Season" with values ranging from 1 to 4.
I am trying to use a loop to perform one-hot-encoding, i.e create 4 new columns called "Season 1" , "Season 2", "Season 3", "Season 4", where each column has a binary indicator value of 1/0 showing whether the Season in the column name is occurring for each data-point. So far I have tried this:</p>
<pre><code>for (i in 1:4){
text<-paste("Season", toString(i), sep = " ")
if (rawData$season==i) {
rawData$text<-1
}
}
</code></pre>
<p>However, I am just getting an additional column in my dataframe called "text" with all values =1. I understand why R is doing this, but I can not figure out an alternative way to make it do what I want. I tried changing the if-then statement to change "rawData$text" to "rawData$paste("Season", toString(i), sep = " ")<-1" but that is giving me an error</p>
| 0debug
|
Initialize a Point2D in List<> : <p>If I have a simple List< Point2D > declared.</p>
<p>Example:</p>
<pre><code>List<Point2D> listOfPoints;
/* What I tried */
Point2D point1;
listOfPoints.add(point1);
</code></pre>
<p>But, how does one initialize <code>point1</code> so that I can have a coordinate of let's say <code>(3,2)</code>?</p>
| 0debug
|
static void sdl_audio_callback(void *opaque, Uint8 *stream, int len)
{
VideoState *is = opaque;
int audio_size, len1, silence = 0;
audio_callback_time = av_gettime_relative();
while (len > 0) {
if (is->audio_buf_index >= is->audio_buf_size) {
audio_size = audio_decode_frame(is);
if (audio_size < 0) {
silence = 1;
is->audio_buf_size = SDL_AUDIO_MIN_BUFFER_SIZE / is->audio_tgt.frame_size * is->audio_tgt.frame_size;
} else {
if (is->show_mode != SHOW_MODE_VIDEO)
update_sample_display(is, (int16_t *)is->audio_buf, audio_size);
is->audio_buf_size = audio_size;
}
is->audio_buf_index = 0;
}
len1 = is->audio_buf_size - is->audio_buf_index;
if (len1 > len)
len1 = len;
if (!is->muted && !silence && is->audio_volume == SDL_MIX_MAXVOLUME)
memcpy(stream, (uint8_t *)is->audio_buf + is->audio_buf_index, len1);
else {
memset(stream, 0, len1);
if (!is->muted && !silence)
SDL_MixAudio(stream, (uint8_t *)is->audio_buf + is->audio_buf_index, len1, is->audio_volume);
}
len -= len1;
stream += len1;
is->audio_buf_index += len1;
}
is->audio_write_buf_size = is->audio_buf_size - is->audio_buf_index;
if (!isnan(is->audio_clock)) {
set_clock_at(&is->audclk, is->audio_clock - (double)(2 * is->audio_hw_buf_size + is->audio_write_buf_size) / is->audio_tgt.bytes_per_sec, is->audio_clock_serial, audio_callback_time / 1000000.0);
sync_clock_to_slave(&is->extclk, &is->audclk);
}
}
| 1threat
|
Python 3: Is not JSON serializable : <pre><code>TypeError: b'Pizza is a flatbread generally topped with tomato sauce and cheese and baked in an oven. It is commonly topped with a selection of meats, vegetables and condiments. The term was first recorded in the 10th century, in a Latin manuscript from Gaeta in Central Italy. The modern pizza was invented in Naples, Italy, and the dish and its variants have since become popular in many areas of the world.\nIn 2009, upon Italy\'s request, Neapolitan pizza was safeguarded in the European Union as a Traditional Speciality Guaranteed dish. The Associazione Verace Pizza Napoletana (the True Neapolitan Pizza Association) is a non-profit organization founded in 1984 with headquarters in Naples. It promotes and protects the "true Neapolitan pizza".\nPizza is sold fresh, frozen or in portions, and is a common fast food item in North America and the United Kingdom. Various types of ovens are used to cook them and many varieties exist. Several similar dishes are prepared from ingredients commonly used in pizza preparation, such as calzone and stromboli.' is not JSON serializable
</code></pre>
<p>I have a program that adds this into a JSON string, which works fine for most text strings - but not this one apparently. Can you tell why not, or how to fix it?</p>
| 0debug
|
clearing border in second table using css : <p>I have created two tables on an html page, I want the first table to have a border but I don't want the second table to have one. How do I make the second table not display a border in css?</p>
| 0debug
|
What is the use of "or" operator with integers : <p>I am not getting what <code>or</code> operator does with inters. I have following code</p>
<pre><code>-1||4 // output -1
4||-1 //output 4
</code></pre>
<p>Does it converts integers in bytes and performs or operation. </p>
| 0debug
|
ENOENT: no such file or directory .? : <p>This is error which am getting while post data and file.
I have followed 'academind' tutorial for building Restful API services, also i have been searching answer for this type of errors but nothing works for me.</p>
<p>Am using "multer" to upload file </p>
<p>The folder 'uploads' available in the folder but it shows</p>
<p>ENOENT: no such file or directory, open 'D:\project\uploads\2018-01-24T07:41:21.832Zcheck.jpg'"</p>
<p>app.js</p>
<pre><code>const express = require("express");
const app = express();
const morgan = require("morgan");
const bodyParser = require("body-parser");
const mongoose = require("mongoose");
const productRoutes = require("./api/routes/products");
mongoose.connect('',
(err)=>{
if(err){console.log(err)}
else{console.log('DB Connected')}
})
mongoose.Promise = global.Promise;
app.use(morgan("dev"));
app.use('/uploads', express.static('uploads'));
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.use((req, res, next) => {
res.header("Access-Control-Allow-Origin", "*");
res.header(
"Access-Control-Allow-Headers",
"Origin, X-Requested-With, Content-Type, Accept, Authorization"
);
if (req.method === "OPTIONS") {
res.header("Access-Control-Allow-Methods", "PUT, POST, PATCH, DELETE, GET");
return res.status(200).json({});
}
next();
});
// Routes which should handle requests
app.use("/products", productRoutes);
app.use((req, res, next) => {
const error = new Error("Not found");
error.status = 404;
next(error);
});
app.use((error, req, res, next) => {
res.status(error.status || 500);
res.json({
error: {
message: error.message
}
});
});
module.exports = app;
</code></pre>
<p>product.js</p>
<pre><code>const express = require("express");
const router = express.Router();
const mongoose = require("mongoose");
const multer = require('multer');
const storage = multer.diskStorage({
destination: function(req, file, cb) {
cb(null, './uploads/');
},
filename: function(req, file, cb) {
cb(null, new Date().toISOString() + file.originalname);
}
});
const fileFilter = (req, file, cb) => {
// reject a file
if (file.mimetype === 'image/jpeg' || file.mimetype === 'image/png') {
cb(null, true);
} else {
cb(null, false);
}
};
const upload = multer({
storage: storage,
limits: {
fileSize: 1024 * 1024 * 5
},
fileFilter: fileFilter
});
router.post("/", checkAuth, upload.single('productImage'), (req, res, next) => {
const product = new Product({
_id: new mongoose.Types.ObjectId(),
name: req.body.name,
price: req.body.price,
productImage: req.file.path
});
product
.save()
.then(result => {
console.log(result);
res.status(201).json({
message: "Created product successfully",
createdProduct: {
name: result.name,
price: result.price,
_id: result._id,
request: {
type: 'GET',
url: "http://localhost:3000/products/" + result._id
}
}
});
})
.catch(err => {
console.log(err);
res.status(500).json({
error: err
});
});
});
module.exports = router;
</code></pre>
| 0debug
|
Could not signal service com.apple.WebKit.WebContent : <p>I use the Shopify Mobile Buy SDK for iOS and I can't get a callback from their payment web view. For some reason the warnings:</p>
<pre><code>2016-11-25 21:17:25.945267 Drool[3328:799969] Could not signal service com.apple.WebKit.WebContent: 113: Could not find specified service
2016-11-25 21:17:25.977316 Drool[3328:799969] Could not signal service com.apple.WebKit.Networking: 113: Could not find specified service
2016-11-25 21:17:26.105947 Drool[3328:799969] [App] if we're in the real pre-commit handler we can't actually add any new fences due to CA restriction
</code></pre>
<p>keep showing up and I have no idea why this is happening and if this is the cause of this problem, do any of you know what this is?</p>
| 0debug
|
SWIFT ARKIT detect the hand and nails, and place the object on the nails? : <p>I would like to know how to detect a person’s hand and nails, and then use ARKIT to place an object on her nails. Frankly, I’ve been looking for information about it for several days in Google, I haven’t found anything that could help me. I would really appreciate if you could help me! Thanks a lot in advance!</p>
| 0debug
|
static int v9fs_synth_truncate(FsContext *ctx, V9fsPath *path, off_t offset)
{
errno = ENOSYS;
return -1;
}
| 1threat
|
Unable to identify source of java.lang.ClassNotFoundException BaseDexClassLoader : <p>I have got lot of crash report in my android app from users as I see in the developer console. The stack trace that I see is:</p>
<pre><code>java.lang.RuntimeException:
at android.app.ActivityThread.handleReceiver (ActivityThread.java:2884)
at android.app.ActivityThread.-wrap14 (ActivityThread.java)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1565)
at android.os.Handler.dispatchMessage (Handler.java:111)
at android.os.Looper.loop (Looper.java:207)
at android.app.ActivityThread.main (ActivityThread.java:5728)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:789)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:679)
Caused by: java.lang.ClassNotFoundException:
at dalvik.system.BaseDexClassLoader.findClass (BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass (ClassLoader.java:511)
at java.lang.ClassLoader.loadClass (ClassLoader.java:469)
at android.app.ActivityThread.handleReceiver (ActivityThread.java:2879)
</code></pre>
<p>There is no reference to my app's package name. I am using Eclipse for my development. Is it something related to multidex. Do I need to switch to Android Studio to solve this. I am unable to understand the basic reason behind the stack trace so that I can look for a solution for it.</p>
<p>Note: I have google play services, IAP and OneSignal Sdk added to my app</p>
| 0debug
|
Python: How to create log file everyday using logging module? : <p>I'm new to logging module of python. I want to create a new log file everyday while my application is in running condition.</p>
<pre><code>log file name - my_app_20170622.log
log file entries within time - 00:00:01 to 23:59:59
</code></pre>
<p>On next day I want to create a new log file with next day's date -</p>
<pre><code>log file name - my_app_20170623.log
log file entries within time - 00:00:01 to 23:59:59
</code></pre>
<p>I'm using logging module of python. </p>
<p>I'm using like below - </p>
<pre><code>log_level = int(log_level)
logger = logging.getLogger('simple')
logger.setLevel(log_level)
fh = logging.FileHandler(log_file_name)
fh.setLevel(log_level)
formatter = logging.Formatter(log_format)
fh.setFormatter(formatter)
logger.addHandler(fh)
</code></pre>
<p>Is their any configurations in logging module of python to create a log on daily basis?</p>
| 0debug
|
python - updated dictionary with same key value pair : <p>I've seem to hit a wall with dictionaries in python.
Is it possible to update a dictionary with the same key value pair.
Whenever I try to update my dictionary with the same key value pair, the update action is not performed, it sort of ignores the pair to update because of duplication. Is there some limitation to updating key value pair duplicates in a python dictionary?</p>
<p>I have posted my code below for demonstration.
Thanks Inadvance.</p>
<pre><code>import time
import collections
from random import randrange
def faceCard(card,cardNum):
cDict = collections.OrderedDict()
print("Card:",card)
if card == 11:
cDict["Jack"] = 10
elif card == 12:
cDict["Queen"] = 10
elif card == 13:
cDict["King"] = 10
elif card == 14:
cDict["Ace"] = 11
else:
cDict[cardNum] = card
return cDict
def main():
pCards = collections.OrderedDict()
dCards = collections.OrderedDict()
while True:
pCards.update(faceCard(randrange(2,15,1),"pCard1"))
time.sleep(.25)
dCards.update(faceCard(randrange(2,15,1),"dCard1"))
time.sleep(.25)
pCards.update(faceCard(randrange(2,15,1),"pCard2"))
time.sleep(.25)
dCards.update(faceCard(randrange(2,15,1),"dCard2"))
time.sleep(.25)
print("Player",pCards)
print("Dealer",dCards)
pCards.clear()
dCards.clear()
if __name__ == "__main__":
main()
</code></pre>
| 0debug
|
int cpu_breakpoint_remove(CPUState *env, target_ulong pc, int flags)
{
#if defined(TARGET_HAS_ICE)
CPUBreakpoint *bp;
TAILQ_FOREACH(bp, &env->breakpoints, entry) {
if (bp->pc == pc && bp->flags == flags) {
cpu_breakpoint_remove_by_ref(env, bp);
return 0;
}
}
return -ENOENT;
#else
return -ENOSYS;
#endif
}
| 1threat
|
static int find_image_range(int *pfirst_index, int *plast_index,
const char *path)
{
char buf[1024];
int range, last_index, range1, first_index;
for(first_index = 0; first_index < 5; first_index++) {
if (av_get_frame_filename(buf, sizeof(buf), path, first_index) < 0){
*pfirst_index =
*plast_index = 1;
if (avio_check(buf, AVIO_FLAG_READ) > 0)
return 0;
return -1;
}
if (avio_check(buf, AVIO_FLAG_READ) > 0)
break;
}
if (first_index == 5)
goto fail;
last_index = first_index;
for(;;) {
range = 0;
for(;;) {
if (!range)
range1 = 1;
else
range1 = 2 * range;
if (av_get_frame_filename(buf, sizeof(buf), path,
last_index + range1) < 0)
goto fail;
if (avio_check(buf, AVIO_FLAG_READ) <= 0)
break;
range = range1;
if (range >= (1 << 30))
goto fail;
}
if (!range)
break;
last_index += range;
}
*pfirst_index = first_index;
*plast_index = last_index;
return 0;
fail:
return -1;
}
| 1threat
|
How can I deal with getActivity() on android studio? :
When I put in this code in my project, it said "Cannot resolve method getActivity"
then, how can I deal with this problem?
| 0debug
|
How to animate list changes in Flutter : <p>If I have a list (of ListTiles for example) that can be added to, removed from, and swapped, what would be the best way to animate these changes? I am using a <a href="https://pub.dartlang.org/packages/flutter_reorderable_list" rel="noreferrer">reorderable list</a> if that makes a difference. Right now my list has no animations, I just call setState when data is changed.</p>
| 0debug
|
void os_set_proc_name(const char *s)
{
#if defined(PR_SET_NAME)
char name[16];
if (!s)
return;
name[sizeof(name) - 1] = 0;
strncpy(name, s, sizeof(name));
if (prctl(PR_SET_NAME, name)) {
perror("unable to change process name");
exit(1);
}
#else
fprintf(stderr, "Change of process name not supported by your OS\n");
exit(1);
#endif
}
| 1threat
|
How to decode JWT Token payload on client side? : <p>I'm using a jwt token for authentication and would like to read the payload information on the client-side. Right now I'm doing something like this:</p>
<pre><code>var payload = JSON.parse(window.atob(token.split('.')[1]));
</code></pre>
<p>Is there a better way to work with jwt tokens within the browser? </p>
| 0debug
|
static void page_flush_tb_1(int level, void **lp)
{
int i;
if (*lp == NULL) {
return;
}
if (level == 0) {
PageDesc *pd = *lp;
for (i = 0; i < L2_SIZE; ++i) {
pd[i].first_tb = NULL;
invalidate_page_bitmap(pd + i);
}
} else {
void **pp = *lp;
for (i = 0; i < L2_SIZE; ++i) {
page_flush_tb_1(level - 1, pp + i);
}
}
}
| 1threat
|
static int avg_bits_per_pixel(int pix_fmt)
{
int bits;
const PixFmtInfo *pf;
pf = &pix_fmt_info[pix_fmt];
if (pf->is_packed) {
switch(pix_fmt) {
case PIX_FMT_RGB24:
case PIX_FMT_BGR24:
bits = 24;
break;
case PIX_FMT_RGBA32:
bits = 32;
break;
case PIX_FMT_RGB565:
case PIX_FMT_RGB555:
bits = 16;
break;
case PIX_FMT_PAL8:
bits = 8;
break;
default:
bits = 32;
break;
}
} else {
bits = pf->depth;
bits += (2 * pf->depth >>
(pf->x_chroma_shift + pf->x_chroma_shift));
}
return bits;
}
| 1threat
|
def test_duplicate(arraynums):
nums_set = set(arraynums)
return len(arraynums) != len(nums_set)
| 0debug
|
Need VBA Help! Been searching for days : I have very little background in VBA but learn quick. I am working on a sheet that is exported from an online system. I have already worked out the VBA to reformat the entire sheet now I am left with my final part that has stumped me.
1. Column B is populated with 78 possible serial numbers (6 digits long). These serial numbers relate to any one of 10 specific machine names. Think of this like Vin numbers to a car.
2. What I would like to do in VBA is populate column A with the machine name based off the serial number listed in B.
3. The machine name is not listed anywhere on the sheet, I was hoping to have that information stored within the formula in VBA.
Below is an example of the data I am working with.
[Example Data][1]
[1]: https://i.stack.imgur.com/VKxgp.jpg
| 0debug
|
static void alloc_aio_bitmap(BlkMigDevState *bmds)
{
BlockDriverState *bs = bmds->bs;
int64_t bitmap_size;
bitmap_size = bdrv_nb_sectors(bs) + BDRV_SECTORS_PER_DIRTY_CHUNK * 8 - 1;
bitmap_size /= BDRV_SECTORS_PER_DIRTY_CHUNK * 8;
bmds->aio_bitmap = g_malloc0(bitmap_size);
}
| 1threat
|
RNTN implementation in java : <p>I want to implement a Recursive neural tensor network(<strong>RNTN</strong>) in java.</p>
<p>I've used Deeplearning4j for word2vec pipeline to vectorize a corpus of words.</p>
<p>for NLP pipeline I've used Opennlp.( for tokenizing, POStaging and parsing)</p>
<p>Now, I figured out that I need an RNTN for my purpose and I didn't find much support, any references would be helpful. Many libraries are written in R or python or even in Scala and the NLP pipeline most of the people used is stanfordnlp. But I want to do this with Opennlp and java.</p>
<p>After that, I would like to combine the word vectors with neural net and then do the task I want to do something like sentiment analysis.</p>
<p>How can I proceed? Any input will be helpful.</p>
<p>Thanks.</p>
| 0debug
|
Play video in objective C : I have a view controller in which I'm trying to play a video. The video is locally added in my project but when I open the view controller it shows any error and app crashes, the error is this,
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSURL initFileURLWithPath:]: nil string parameter'
My code is this,
NSString *path=[[NSBundle mainBundle]pathForResource:@"Video" ofType:@"mp4"];
NSURL *url = [NSURL fileURLWithPath:path];
AVPlayer *player = [AVPlayer playerWithURL:url];
AVPlayerViewController *controller = [[AVPlayerViewController alloc]init];
controller.view.frame = self.view.bounds;
[self.view addSubview:controller.view];
[player play];
| 0debug
|
static inline TCGOp *tcg_emit_op(TCGOpcode opc)
{
TCGContext *ctx = tcg_ctx;
int oi = ctx->gen_next_op_idx;
int ni = oi + 1;
int pi = oi - 1;
TCGOp *op = &ctx->gen_op_buf[oi];
tcg_debug_assert(oi < OPC_BUF_SIZE);
ctx->gen_op_buf[0].prev = oi;
ctx->gen_next_op_idx = ni;
memset(op, 0, offsetof(TCGOp, args));
op->opc = opc;
op->prev = pi;
op->next = ni;
return op;
}
| 1threat
|
How get random item from es6 Map or Set : <p>I have a project that uses arrays of objects that I'm thinking of moving to es6 Sets or Maps. </p>
<p>I need to quickly get a random item from them (obviously trivial for my current arrays). How would I do this?</p>
| 0debug
|
How do I force a refresh on an Observable service in Angular2? : <p>In <code>ngOnInit</code>, my component obtains a list of users like so:</p>
<pre><code>this.userService.getUsers().subscribe(users => {
this.users = users;
});
</code></pre>
<p>And the implementation of userService.getUsers() looks like this:</p>
<pre><code>getUsers() : Observable<UserModel[]> {
return this.http.get('http://localhost:3000/api/user')
.map((res: Response) => <UserModel[]>res.json().result)
.catch((error: any) => Observable.throw(error.json().error || 'Internal error occurred'));
}
</code></pre>
<p>Now, in another component, I have a form that can create a new user. The problem is that when I use that second component to create a user, the first component doesn't know that it should make a new GET request to the backend to refresh its view of users. How can I tell it to do so?</p>
<p>I know that ideally I'd want to skip that extra HTTP GET request, and simply append the data the client already has from when it made the POST to insert the data, but I'm wondering how it'd be done in the case where that's not possible for whatever reason.</p>
| 0debug
|
static ssize_t nbd_send_reply(int csock, struct nbd_reply *reply)
{
uint8_t buf[4 + 4 + 8];
cpu_to_be32w((uint32_t*)buf, NBD_REPLY_MAGIC);
cpu_to_be32w((uint32_t*)(buf + 4), reply->error);
cpu_to_be64w((uint64_t*)(buf + 8), reply->handle);
TRACE("Sending response to client");
if (write_sync(csock, buf, sizeof(buf)) != sizeof(buf)) {
LOG("writing to socket failed");
errno = EINVAL;
return -1;
}
return 0;
}
| 1threat
|
Convert RxJava Observables To Live Data With Kotlin Extension Functions : <p>I've been using alot of RxJava <code>Observables</code> converted to <code>LiveData</code> in my code using <code>LiveDataReactiveStreams.fromPublisher()</code> library. So I though of adding an extension function to the RxJava Observable to easily convert them to <code>LiveData</code>.</p>
<p>These are my extension functions:</p>
<pre><code>fun <T> Flowable<T>.toLiveData() : LiveData<T> {
return LiveDataReactiveStreams.fromPublisher(this)
}
fun <T> Observable<T>.toLiveData(backPressureStrategy: BackpressureStrategy) : LiveData<T> {
return LiveDataReactiveStreams.fromPublisher(this.toFlowable(backPressureStrategy))
}
fun <T> Single<T>.toLiveData() : LiveData<T> {
return LiveDataReactiveStreams.fromPublisher(this.toFlowable())
}
fun <T> Maybe<T>.toLiveData() : LiveData<T> {
return LiveDataReactiveStreams.fromPublisher(this.toFlowable())
}
fun <T> Completable.toLiveData() : LiveData<T> {
return LiveDataReactiveStreams.fromPublisher(this.toFlowable())
}
</code></pre>
<p>My questions are:</p>
<ol>
<li>Is this a good idea?</li>
<li>Is there a better way of doing this?</li>
<li>Could these extension functions be better?</li>
</ol>
<p>P.S.</p>
<p>I'm new to Kotlin and so I am asking these question. Anything helpful would be appreciated. Thank you very much.</p>
| 0debug
|
How can I randomly select a question from an external file using python : <p>I want to include questions in an external file using python. Then be able to randomly select a question and let the user enter in the answer, then select another random question? Also with a point system when answer is answered correctly. Any help would be much appreciated. </p>
| 0debug
|
static long getrampagesize(void)
{
long hpsize = LONG_MAX;
Object *memdev_root;
if (mem_path) {
return gethugepagesize(mem_path);
}
memdev_root = object_resolve_path("/objects", NULL);
if (!memdev_root) {
return getpagesize();
}
object_child_foreach(memdev_root, find_max_supported_pagesize, &hpsize);
if (hpsize == LONG_MAX) {
return getpagesize();
}
if (nb_numa_nodes == 0 && hpsize > getpagesize()) {
static bool warned;
if (!warned) {
error_report("Huge page support disabled (n/a for main memory).");
warned = true;
}
return getpagesize();
}
return hpsize;
}
| 1threat
|
static void v9fs_wstat(void *opaque)
{
int32_t fid;
int err = 0;
int16_t unused;
V9fsStat v9stat;
size_t offset = 7;
struct stat stbuf;
V9fsFidState *fidp;
V9fsPDU *pdu = opaque;
V9fsState *s = pdu->s;
pdu_unmarshal(pdu, offset, "dwS", &fid, &unused, &v9stat);
fidp = get_fid(pdu, fid);
if (fidp == NULL) {
err = -EINVAL;
goto out_nofid;
}
if (donttouch_stat(&v9stat)) {
err = v9fs_co_fsync(pdu, fidp, 0);
goto out;
}
if (v9stat.mode != -1) {
uint32_t v9_mode;
err = v9fs_co_lstat(pdu, &fidp->path, &stbuf);
if (err < 0) {
goto out;
}
v9_mode = stat_to_v9mode(&stbuf);
if ((v9stat.mode & P9_STAT_MODE_TYPE_BITS) !=
(v9_mode & P9_STAT_MODE_TYPE_BITS)) {
err = -EIO;
goto out;
}
err = v9fs_co_chmod(pdu, &fidp->path,
v9mode_to_mode(v9stat.mode,
&v9stat.extension));
if (err < 0) {
goto out;
}
}
if (v9stat.mtime != -1 || v9stat.atime != -1) {
struct timespec times[2];
if (v9stat.atime != -1) {
times[0].tv_sec = v9stat.atime;
times[0].tv_nsec = 0;
} else {
times[0].tv_nsec = UTIME_OMIT;
}
if (v9stat.mtime != -1) {
times[1].tv_sec = v9stat.mtime;
times[1].tv_nsec = 0;
} else {
times[1].tv_nsec = UTIME_OMIT;
}
err = v9fs_co_utimensat(pdu, &fidp->path, times);
if (err < 0) {
goto out;
}
}
if (v9stat.n_gid != -1 || v9stat.n_uid != -1) {
err = v9fs_co_chown(pdu, &fidp->path, v9stat.n_uid, v9stat.n_gid);
if (err < 0) {
goto out;
}
}
if (v9stat.name.size != 0) {
err = v9fs_complete_rename(pdu, fidp, -1, &v9stat.name);
if (err < 0) {
goto out;
}
}
if (v9stat.length != -1) {
err = v9fs_co_truncate(pdu, &fidp->path, v9stat.length);
if (err < 0) {
goto out;
}
}
err = offset;
out:
put_fid(pdu, fidp);
out_nofid:
v9fs_stat_free(&v9stat);
complete_pdu(s, pdu, err);
}
| 1threat
|
envlist_unsetenv(envlist_t *envlist, const char *env)
{
struct envlist_entry *entry;
size_t envname_len;
if ((envlist == NULL) || (env == NULL))
return (EINVAL);
if (strchr(env, '=') != NULL)
return (EINVAL);
envname_len = strlen(env);
for (entry = envlist->el_entries.lh_first; entry != NULL;
entry = entry->ev_link.le_next) {
if (strncmp(entry->ev_var, env, envname_len) == 0)
break;
}
if (entry != NULL) {
LIST_REMOVE(entry, ev_link);
free((char *)entry->ev_var);
free(entry);
envlist->el_count--;
}
return (0);
}
| 1threat
|
struct pxa2xx_lcdc_s *pxa2xx_lcdc_init(target_phys_addr_t base, qemu_irq irq,
DisplayState *ds)
{
int iomemtype;
struct pxa2xx_lcdc_s *s;
s = (struct pxa2xx_lcdc_s *) qemu_mallocz(sizeof(struct pxa2xx_lcdc_s));
s->base = base;
s->invalidated = 1;
s->irq = irq;
s->ds = ds;
pxa2xx_lcdc_orientation(s, graphic_rotate);
iomemtype = cpu_register_io_memory(0, pxa2xx_lcdc_readfn,
pxa2xx_lcdc_writefn, s);
cpu_register_physical_memory(base, 0x000fffff, iomemtype);
graphic_console_init(ds, pxa2xx_update_display,
pxa2xx_invalidate_display, pxa2xx_screen_dump, s);
switch (s->ds->depth) {
case 0:
s->dest_width = 0;
break;
case 8:
s->line_fn[0] = pxa2xx_draw_fn_8;
s->line_fn[1] = pxa2xx_draw_fn_8t;
s->dest_width = 1;
break;
case 15:
s->line_fn[0] = pxa2xx_draw_fn_15;
s->line_fn[1] = pxa2xx_draw_fn_15t;
s->dest_width = 2;
break;
case 16:
s->line_fn[0] = pxa2xx_draw_fn_16;
s->line_fn[1] = pxa2xx_draw_fn_16t;
s->dest_width = 2;
break;
case 24:
s->line_fn[0] = pxa2xx_draw_fn_24;
s->line_fn[1] = pxa2xx_draw_fn_24t;
s->dest_width = 3;
break;
case 32:
s->line_fn[0] = pxa2xx_draw_fn_32;
s->line_fn[1] = pxa2xx_draw_fn_32t;
s->dest_width = 4;
break;
default:
fprintf(stderr, "%s: Bad color depth\n", __FUNCTION__);
exit(1);
}
register_savevm("pxa2xx_lcdc", 0, 0,
pxa2xx_lcdc_save, pxa2xx_lcdc_load, s);
return s;
}
| 1threat
|
Logical OR in for loop in Matlab : I want to add an additional condition in for loop.
for(i=1; (i<100)&&(something>0.001) ; i++)
{
//do something
}
How can I implement this in Matlab?
| 0debug
|
void video_decode_example(const char *outfilename, const char *filename)
{
AVCodec *codec;
AVCodecContext *c= NULL;
int frame, size, got_picture, len;
FILE *f;
AVFrame *picture;
uint8_t inbuf[INBUF_SIZE + FF_INPUT_BUFFER_PADDING_SIZE], *inbuf_ptr;
char buf[1024];
memset(inbuf + INBUF_SIZE, 0, FF_INPUT_BUFFER_PADDING_SIZE);
printf("Video decoding\n");
codec = avcodec_find_decoder(CODEC_ID_MPEG1VIDEO);
if (!codec) {
fprintf(stderr, "codec not found\n");
exit(1);
}
c= avcodec_alloc_context();
picture= avcodec_alloc_frame();
if(codec->capabilities&CODEC_CAP_TRUNCATED)
c->flags|= CODEC_FLAG_TRUNCATED;
if (avcodec_open(c, codec) < 0) {
fprintf(stderr, "could not open codec\n");
exit(1);
}
f = fopen(filename, "r");
if (!f) {
fprintf(stderr, "could not open %s\n", filename);
exit(1);
}
frame = 0;
for(;;) {
size = fread(inbuf, 1, INBUF_SIZE, f);
if (size == 0)
break;
inbuf_ptr = inbuf;
while (size > 0) {
len = avcodec_decode_video(c, picture, &got_picture,
inbuf_ptr, size);
if (len < 0) {
fprintf(stderr, "Error while decoding frame %d\n", frame);
exit(1);
}
if (got_picture) {
printf("saving frame %3d\n", frame);
fflush(stdout);
snprintf(buf, sizeof(buf), outfilename, frame);
pgm_save(picture->data[0], picture->linesize[0],
c->width, c->height, buf);
frame++;
}
size -= len;
inbuf_ptr += len;
}
}
len = avcodec_decode_video(c, picture, &got_picture,
NULL, 0);
if (got_picture) {
printf("saving last frame %3d\n", frame);
fflush(stdout);
snprintf(buf, sizeof(buf), outfilename, frame);
pgm_save(picture->data[0], picture->linesize[0],
c->width, c->height, buf);
frame++;
}
fclose(f);
avcodec_close(c);
free(c);
free(picture);
printf("\n");
}
| 1threat
|
How to line break long large title in iOS 13? : <p>As title, is there a way to split long large titles in UINavigationBar?</p>
<p>I tried all those methods, working for iOS 11 but none of them seem work to me on iOS 13</p>
<p><a href="https://stackoverflow.com/questions/47901318/how-to-set-multi-line-large-title-in-navigation-bar-new-feature-of-ios-11/51295457">How to set multi line Large title in navigation bar? ( New feature of iOS 11)</a></p>
| 0debug
|
hellow guys iam new to web design ,i want to make a responsive design as shown below using bootstrap please respond : [enter image description here][1]
[1]: https://i.stack.imgur.com/BCHwt.jpg
here is a code i tried but not working especiall in mobile view
<div class="col-sm-4">
<div class="product_body">
<div class="prod_image">
<img src="images/product/1.png">
</div>
<div class="prod_details">
<h4>Teddy bear</h4>
<div class="row">
<div class="col-xs-12 col-md-6 prod_price">
RS 333
</div>
<div class="col-xs-12 col-md-6 prod_offer">
88% OFF
</div>
</div>
</div>
</div>
</div>
| 0debug
|
void *fw_cfg_modify_file(FWCfgState *s, const char *filename,
void *data, size_t len)
{
int i, index;
void *ptr = NULL;
assert(s->files);
index = be32_to_cpu(s->files->count);
assert(index < fw_cfg_file_slots(s));
for (i = 0; i < index; i++) {
if (strcmp(filename, s->files->f[i].name) == 0) {
ptr = fw_cfg_modify_bytes_read(s, FW_CFG_FILE_FIRST + i,
data, len);
s->files->f[i].size = cpu_to_be32(len);
return ptr;
}
}
fw_cfg_add_file_callback(s, filename, NULL, NULL, NULL, data, len, true);
return NULL;
}
| 1threat
|
Type inside angle brackets - what does it mean? : <p>While working on somebodys else code I found some weird construction, which for I couldnt find any explanation on the internet. Here is the whole method from JavaFXML Application:</p>
<pre><code>private void logInUser(User selectedUser) throws IOException {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/movierecsys/gui/view/MovieRecView.fxml"));
Parent root1 = (Parent) fxmlLoader.load();
fxmlLoader.<MovieRecController>getController().setInfo(selectedUser);
Stage stage = (Stage) loginButton.getScene().getWindow();
stage.setScene(new Scene(root1));
stage.show();
}
</code></pre>
<p>And here is the line which is not really clear for me:</p>
<pre><code> fxmlLoader.<MovieRecController>getController().setInfo(selectedUser);
</code></pre>
<p>What exactly means <code><MovieRecController></code> ? It looks like type casting, but i have never met before this construction for casting and I could find any explanation for this. </p>
| 0debug
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.