problem
stringlengths
26
131k
labels
class label
2 classes
What's the proper way to implement formatting on v-model in Vue.js 2.0 : <p>For a simple example: textbox to input currency data. The requirement is to display user input in "$1,234,567" format and remove decimal point.</p> <p>I have tried vue directive. directive's update method is not called when UI is refreshed due to other controls. so value in textbox reverts to the one without any formatting.</p> <p>I also tried v-on:change event handler. But I don't know how to call a global function in event handler. It is not a good practice to create a currency convert method in every Vue object.</p> <p>So what is the standard way of formatting in Vue 2.0 now?</p> <p>Regards</p>
0debug
Difference of Product and Sum of Digits : <p>The task is to find the difference in the products of the digits and sum of digits. For example, an input of <code>4 5 6</code> would give <code>105</code>. The issue I'm having is dealing with previous iterations. I know it has something to do with the indexes of the list but I'm having difficulty figuring it out. Here's my code:</p> <pre><code># find the difference between the product of all digits and sum of all digits nums = input() nums = list(nums.split()) def findProduct(): for i in range(len(nums)): int(nums[i]) *= int(nums[i+1]) findProduct() </code></pre>
0debug
Why redeclaration of variable is allowed inside loop and if condition which are declared out side of loop or if condition already? : <pre><code>#include &lt;stdio.h&gt; int main() { int a=9; if(a&lt;10){ int a = 20; ++a; printf("%d\n",a); } printf("%d\n",a); } </code></pre> <p>Why redeclaration of a is allowed in loop and if condition here?<br> Why can't we increment or decrement variable inside loop or if statement which are delclared outside of loop or if statement??</p>
0debug
void helper_lsl(void) { unsigned int selector, limit; uint32_t e1, e2; CC_SRC = cc_table[CC_OP].compute_all() & ~CC_Z; selector = T0 & 0xffff; if (load_segment(&e1, &e2, selector) != 0) return; limit = (e1 & 0xffff) | (e2 & 0x000f0000); if (e2 & (1 << 23)) limit = (limit << 12) | 0xfff; T1 = limit; CC_SRC |= CC_Z; }
1threat
Error javascript : <p>In console, I have this error. I use the latest jquery 3.1.</p> <p>How to rectify this element ?</p> <p>Thank you</p> <p>typeError: window.on is not a function</p> <pre><code>&lt;script&gt;(window).on('load', function (){var maxHeight=0;$(".equal-height").each(function(){if($(this).height()&gt;maxHeight){maxHeight=$(this).height();}});$(".equal-height").height(maxHeight);});&lt;/script&gt; </code></pre>
0debug
How can I ask Bazel to rerun a cached test? : <p>I'm trying to analyze and fix a flaky test which is often green.<br> My problem is that once the test passes Bazel doesn't re-run it until any of the inputs have changed.<br> I saw you can ask Bazel to re-run a target but AFAICT it's only until the first time it's green (i.e. to mitigate a flaky test and not solve it). </p> <p>Is there a way to ask Bazel to run the test even if it passed?<br> I'd like something like <code>bazel test --force-attempts=50 //my-package:my-target</code></p>
0debug
Find specific item in an array? : <p>I have an array that looks like this:</p> <pre><code>cardNumber: "2344234454562036" cardType: "Visa" cardholderName: "Yeyy" cvv: "123" expiryMonth: 12 expiryYear: 2022 postalCode: "52636" redactedCardNumber: "••••••••••••2036" __proto__: —' </code></pre> <p>I need to get the value of <code>redactedCardNumber</code> from that array.</p> <p>The first thing that I am confused about is that when i print the above 'array' in the console, it actually show an <strong>object</strong> before everything! so is this an <code>array</code> or an <code>object</code>?</p> <p>also, what is the best way of getting the specific item like '<code>redactedCardNumber</code>' from it?</p>
0debug
static void mdct512(AC3MDCTContext *mdct, int32_t *out, int16_t *in) { int i, re, im, n, n2, n4; int16_t *rot = mdct->rot_tmp; IComplex *x = mdct->cplx_tmp; n = 1 << mdct->nbits; n2 = n >> 1; n4 = n >> 2; for (i = 0; i <n4; i++) rot[i] = -in[i + 3*n4]; memcpy(&rot[n4], &in[0], 3*n4*sizeof(*in)); for (i = 0; i < n4; i++) { re = ((int)rot[ 2*i] - (int)rot[ n-1-2*i]) >> 1; im = -((int)rot[n2+2*i] - (int)rot[n2-1-2*i]) >> 1; CMUL(x[i].re, x[i].im, re, im, -mdct->xcos1[i], mdct->xsin1[i], 15); } fft(mdct, x, mdct->nbits - 2); for (i = 0; i < n4; i++) { re = x[i].re; im = x[i].im; CMUL(out[n2-1-2*i], out[2*i], re, im, mdct->xsin1[i], mdct->xcos1[i], 0); } }
1threat
Need Help ! How to add a custom font this activity? : > Hello Evrybody i hope u are fine:) first word happy new year, please i have a problem with this activity file i tried to modify i mean to add acustom font this TextView , i tried many code , it doesn't work for me . hope i will find the solution by this Question. this my activty code: private ArrayList<SongInfo> items; private Context context; private ArrayList<ViewHolder> listHolder = new ArrayList<ListRingtonesAdapter.ViewHolder>(); private int curPosition = 0; private RingtonesSharedPreferences pref; private boolean inRingtones; static final String TAG = "LOG"; private static final int DEFAULT_RINGTONE = 1; private static final int ASSIGN_TO_CONTACT = 2; private static final int DEFAULT_NOTIFICATION = 3; private static final int DEFAULT_ALARM = 4; private static final int DELETE_RINGTONE = 5; public static final String ALARM_PATH = "/media/audio/alarms/"; public static final String ALARM_TYPE = "Alarm"; public static final String NOTIFICATION_PATH = "/media/audio/notifications/"; public static final String NOTIFICATION_TYPE = "Notification"; public static final String RINGTONE_PATH = "/media/audio/ringtones/"; public static final String RINGTONE_TYPE = "Ringtone"; public ListRingtonesAdapter(Context context, int viewResourceId, ArrayList<SongInfo> objects, boolean inRingtones) { super(context, viewResourceId, objects); // TODO Auto-generated constructor stub this.context = context; this.items = objects; this.pref = new RingtonesSharedPreferences(context); this.inRingtones = inRingtones; if(Main.mp.isPlaying()){ Main.mp.stop(); } } @Override public View getView(final int position, View convertView, ViewGroup parent) { // TODO Auto-generated method stub ActionItem defRingtone = new ActionItem(DEFAULT_RINGTONE, "Default Ringtone", context.getResources().getDrawable( R.drawable.icon_ringtone)); ActionItem assign = new ActionItem(ASSIGN_TO_CONTACT, "Contact Ringtone", context.getResources().getDrawable( R.drawable.icon_contact)); ActionItem defNotifi = new ActionItem(DEFAULT_NOTIFICATION, "Default Notification", context.getResources().getDrawable( R.drawable.icon_notify)); ActionItem defAlarm = new ActionItem(DEFAULT_ALARM, "Default Alarm", context.getResources().getDrawable(R.drawable.icon_alarm)); final QuickAction mQuickAction = new QuickAction(context); mQuickAction.addActionItem(defRingtone); mQuickAction.addActionItem(assign); mQuickAction.addActionItem(defNotifi); mQuickAction.addActionItem(defAlarm); // setup the action item click listener mQuickAction .setOnActionItemClickListener(new QuickAction.OnActionItemClickListener() { @Override public void onItemClick(QuickAction quickAction, int pos, int actionId) { switch (actionId) { case DEFAULT_RINGTONE: setDefaultRingtone(items.get(curPosition)); Toast.makeText(context, "Ringtone set successfully", Toast.LENGTH_LONG).show(); break; case ASSIGN_TO_CONTACT: Intent intent = new Intent(context, SelectContactActivity.class); intent.putExtra("position", curPosition); context.startActivity(intent); break; case DEFAULT_ALARM: setDefaultAlarm(items.get(curPosition)); Toast.makeText(context, "Alarm set successfully", Toast.LENGTH_LONG).show(); break; case DEFAULT_NOTIFICATION: setDefaultNotice(items.get(curPosition)); Toast.makeText(context, "Notification set successfully", Toast.LENGTH_LONG).show(); break; default: break; } } }); // setup on dismiss listener, set the icon back to normal mQuickAction.setOnDismissListener(new PopupWindow.OnDismissListener() { @Override public void onDismiss() { } }); View view = null; if (convertView == null) { LayoutInflater li = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); view = li.inflate(R.layout.listelement, null); final ViewHolder holder = new ViewHolder(); holder.txtName = (TextView) view.findViewById(R.id.txtSongName); holder.btnFavorite = (ImageView) view.findViewById(R.id.btnFavorite); holder.btnPlayPause = (ImageView) view.findViewById(R.id.btnPlayPause); view.setTag(holder); } else { } final SongInfo item = items.get(position); if (item != null) { final ViewHolder holder = (ViewHolder) view.getTag(); holder.txtName.setText(item.getName()); if (item.isFavorite()) { holder.btnFavorite.setBackgroundResource(R.drawable.icon_favorite); } else { holder.btnFavorite.setBackgroundResource(R.drawable.icon_favorite_off); } if (!item.isPlaying()) { holder.btnPlayPause.setBackgroundResource(R.drawable.icon_play); } else { holder.btnPlayPause.setBackgroundResource(R.drawable.icon_pause); } holder.btnPlayPause.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub if (Main.mp.isPlaying()) { Main.mp.stop(); } for(int i = 0; i < items.size(); i++){ if(items.get(i) != item) items.get(i).setPlaying(false); } for(int i = 0; i < listHolder.size(); i++){ listHolder.get(i).btnPlayPause.setBackgroundResource(R.drawable.icon_play); } if (item.isPlaying()) { holder.btnPlayPause.setBackgroundResource(R.drawable.icon_play); item.setPlaying(false); items.get(position).setPlaying(false); if (Main.mp.isPlaying()) { Main.mp.stop(); } } else { curPosition = position; playAudio(context, item.getAudioResource()); holder.btnPlayPause.setBackgroundResource(R.drawable.icon_pause); item.setPlaying(true); items.get(position).setPlaying(true); } for (ViewHolder object : listHolder) { if (object != holder) { object.btnPlayPause.setBackgroundResource(R.drawable.icon_play); } } } }); holder.btnFavorite.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub if (item.isFavorite()) { holder.btnFavorite .setBackgroundResource(R.drawable.icon_favorite_off); item.setFavorite(false); pref.setString(item.getFileName(), false); if (!inRingtones) { Intent broadcast = new Intent(); broadcast.setAction("REMOVE_SONG"); context.sendBroadcast(broadcast); } } else { holder.btnFavorite .setBackgroundResource(R.drawable.icon_favorite); item.setFavorite(true); pref.setString(item.getFileName(), true); } } }); listHolder.add(holder); view.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub mQuickAction.show(v); curPosition = position; } }); } return view; } private Object getAssets() { // TODO Auto-generated method stub return null; } private TextView findViewById(int txtsongname) { // TODO Auto-generated method stub return null; } static class ViewHolder { private TextView txtName; private ImageView btnFavorite; private ImageView btnPlayPause; } private void playAudio(Context context, int id) { if (Main.mp.isPlaying()) { Main.mp.stop(); } Main.mp = MediaPlayer.create(context, id); Main.mp.setOnCompletionListener(playCompletionListener); Main.mp.start(); onRingtonePlay.onPlay(); } private OnCompletionListener playCompletionListener = new OnCompletionListener() { @Override public void onCompletion(MediaPlayer mp) { // TODO Auto-generated method stub for(int i = 0; i < items.size(); i++){ items.get(i).setPlaying(false); } for(int i = 0; i < listHolder.size(); i++){ listHolder.get(i).btnPlayPause .setBackgroundResource(R.drawable.icon_play); } } }; private void setRingtone(SongInfo info, boolean ringtone, boolean alarm, boolean music, boolean notification) { File dir = null; String what = null; if (ringtone) { what = "Ringtones"; }else if(alarm){ what = "alarms"; }else if(notification){ what = "notifications"; }else{ what = "Ringtones"; } if (Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED)) { dir = new File(Environment.getExternalStorageDirectory(),what); } else { dir = context.getCacheDir(); } if (!dir.exists()) { dir.mkdirs(); } File file = new File(dir, info.getFileName()); if (!file.exists()) { try { file.createNewFile(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { InputStream inputStream = context.getResources() .openRawResource(info.getAudioResource()); OutputStream outputStream = new FileOutputStream(file); byte[] buffer = new byte[1024]; int length; while ((length = inputStream.read(buffer)) > 0) { outputStream.write(buffer, 0, length); } outputStream.flush(); outputStream.close(); inputStream.close(); } catch (Exception e) { // TODO: handle exception } } context.sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE)); Uri uri = MediaStore.Audio.Media.getContentUriForPath(file.getAbsolutePath()); String[] projection = new String[] { MediaStore.MediaColumns.DATA, MediaStore.Audio.Media.IS_RINGTONE, MediaStore.Audio.Media.IS_ALARM, MediaStore.Audio.Media.IS_MUSIC, MediaStore.Audio.Media.IS_NOTIFICATION }; Cursor c = context.getContentResolver().query(uri,projection,MediaStore.MediaColumns.DATA + " = \"" + file.getAbsolutePath()+ "\"", null, null); String strRingtone = null, strAlarm = null, strNotifi = null, strMusic = null; while (c.moveToNext()) { strRingtone = c.getString(c .getColumnIndex(MediaStore.Audio.Media.IS_RINGTONE)); strAlarm = c.getString(c .getColumnIndex(MediaStore.Audio.Media.IS_ALARM)); strNotifi = c.getString(c .getColumnIndex(MediaStore.Audio.Media.IS_NOTIFICATION)); strMusic = c.getString(c .getColumnIndex(MediaStore.Audio.Media.IS_MUSIC)); } if (ringtone) { if ((strAlarm != null) && (strAlarm.equals("1"))) alarm = true; if ((strNotifi != null) && (strNotifi.equals("1"))) notification = true; if ((strMusic != null) && (strMusic.equals("1"))) music = true; } else if (notification) { if ((strAlarm != null) && (strAlarm.equals("1"))) alarm = true; if ((strRingtone != null) && (strRingtone.equals("1"))) ringtone = true; if ((strMusic != null) && (strMusic.equals("1"))) music = true; } else if (alarm) { if ((strNotifi != null) && (strNotifi.equals("1"))) notification = true; if ((strRingtone != null) && (strRingtone.equals("1"))) ringtone = true; if ((strMusic != null) && (strMusic.equals("1"))) music = true; } else if (music) { if ((strNotifi != null) && (strNotifi.equals("1"))) notification = true; if ((strRingtone != null) && (strRingtone.equals("1"))) ringtone = true; if ((strAlarm != null) && (strAlarm.equals("1"))) alarm = true; } ContentValues values = new ContentValues(); values.put(MediaStore.MediaColumns.DATA, file.getAbsolutePath()); values.put(MediaStore.MediaColumns.TITLE, info.getName()); values.put(MediaStore.MediaColumns.SIZE, file.length()); values.put(MediaStore.MediaColumns.MIME_TYPE, "audio/mp3"); if (ringtone) { values.put(MediaStore.Audio.Media.IS_RINGTONE, ringtone); } else if (notification) { values.put(MediaStore.Audio.Media.IS_NOTIFICATION, notification); } else if (alarm) { values.put(MediaStore.Audio.Media.IS_ALARM, alarm); } else if (music) { values.put(MediaStore.Audio.Media.IS_MUSIC, music); } context.getContentResolver().delete(uri,MediaStore.MediaColumns.DATA + " = \"" + file.getAbsolutePath() + "\"", null); Uri newUri = context.getContentResolver().insert(uri, values); int type = RingtoneManager.TYPE_ALL; if (ringtone) type = RingtoneManager.TYPE_RINGTONE; if (alarm) type = RingtoneManager.TYPE_ALARM; if (notification) type = RingtoneManager.TYPE_NOTIFICATION; RingtoneManager.setActualDefaultRingtoneUri(context, type, newUri); } private void setDefaultRingtone(SongInfo info) { File dir = null; String what = "Ringtones"; Uri newUri = null; ContentValues values = new ContentValues(); boolean isRingTone = false; if (Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED)) { dir = new File(Environment.getExternalStorageDirectory(),what); } else { dir = context.getCacheDir(); } if (!dir.exists()) { dir.mkdirs(); } File file = new File(dir, info.getFileName()); if (!file.exists()) { try { file.createNewFile(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { InputStream inputStream = context.getResources() .openRawResource(info.getAudioResource()); OutputStream outputStream = new FileOutputStream(file); byte[] buffer = new byte[1024]; int length; while ((length = inputStream.read(buffer)) > 0) { outputStream.write(buffer, 0, length); } outputStream.flush(); outputStream.close(); inputStream.close(); } catch (Exception e) { // TODO: handle exception } } context.sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE)); String[] columns = { MediaStore.Audio.Media.DATA, MediaStore.Audio.Media._ID, MediaStore.Audio.Media.IS_RINGTONE }; Cursor cursor = context.getContentResolver().query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, columns, MediaStore.Audio.Media.DATA+" = '"+file.getAbsolutePath()+"'",null, null); if (cursor!=null) { int idColumn = cursor.getColumnIndex(MediaStore.Audio.Media._ID); int fileColumn = cursor.getColumnIndex(MediaStore.Audio.Media.DATA); int ringtoneColumn = cursor.getColumnIndex(MediaStore.Audio.Media.IS_RINGTONE); while (cursor.moveToNext()) { String audioFilePath = cursor.getString(fileColumn); if (cursor.getString(ringtoneColumn)!=null && cursor.getString(ringtoneColumn).equals("1")) { Uri hasUri = MediaStore.Audio.Media.getContentUriForPath(audioFilePath); newUri = Uri.withAppendedPath(hasUri, cursor.getString(idColumn)); isRingTone = true; } } cursor.close(); } if (isRingTone) { RingtoneManager.setActualDefaultRingtoneUri(context, RingtoneManager.TYPE_RINGTONE, newUri); }else{ values.put(MediaStore.MediaColumns.DATA, file.getAbsolutePath()); values.put(MediaStore.MediaColumns.TITLE, info.getName()); values.put(MediaStore.MediaColumns.SIZE, file.length()); values.put(MediaStore.MediaColumns.MIME_TYPE, "audio/mp3"); values.put(MediaStore.Audio.Media.IS_RINGTONE, true); newUri = context.getContentResolver().insert(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, values); RingtoneManager.setActualDefaultRingtoneUri(context, RingtoneManager.TYPE_RINGTONE, newUri); } } private void setDefaultAlarm(SongInfo info) { File dir = null; String what = "alarms"; Uri newUri = null; ContentValues values = new ContentValues(); boolean isRingTone = false; if (Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED)) { dir = new File(Environment.getExternalStorageDirectory(),what); } else { dir = context.getCacheDir(); } if (!dir.exists()) { dir.mkdirs(); } File file = new File(dir, info.getFileName()); if (!file.exists()) { try { file.createNewFile(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { InputStream inputStream = context.getResources() .openRawResource(info.getAudioResource()); OutputStream outputStream = new FileOutputStream(file); byte[] buffer = new byte[1024]; int length; while ((length = inputStream.read(buffer)) > 0) { outputStream.write(buffer, 0, length); } outputStream.flush(); outputStream.close(); inputStream.close(); } catch (Exception e) { // TODO: handle exception } } context.sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE)); String[] columns = { MediaStore.Audio.Media.DATA, MediaStore.Audio.Media._ID, MediaStore.Audio.Media.IS_ALARM }; Cursor cursor = context.getContentResolver().query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, columns, MediaStore.Audio.Media.DATA+" = '"+file.getAbsolutePath()+"'",null, null); if (cursor!=null) { int idColumn = cursor.getColumnIndex(MediaStore.Audio.Media._ID); int fileColumn = cursor.getColumnIndex(MediaStore.Audio.Media.DATA); int ringtoneColumn = cursor.getColumnIndex(MediaStore.Audio.Media.IS_ALARM); while (cursor.moveToNext()) { String audioFilePath = cursor.getString(fileColumn); if (cursor.getString(ringtoneColumn)!=null && cursor.getString(ringtoneColumn).equals("1")) { Uri hasUri = MediaStore.Audio.Media.getContentUriForPath(audioFilePath); newUri = Uri.withAppendedPath(hasUri, cursor.getString(idColumn)); isRingTone = true; } } cursor.close(); } if (isRingTone) { RingtoneManager.setActualDefaultRingtoneUri(context, RingtoneManager.TYPE_ALARM, newUri); }else{ values.put(MediaStore.MediaColumns.DATA, file.getAbsolutePath()); values.put(MediaStore.MediaColumns.TITLE, info.getName()); values.put(MediaStore.MediaColumns.SIZE, file.length()); values.put(MediaStore.MediaColumns.MIME_TYPE, "audio/mp3"); values.put(MediaStore.Audio.Media.IS_ALARM, true); newUri = context.getContentResolver().insert(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, values); RingtoneManager.setActualDefaultRingtoneUri(context, RingtoneManager.TYPE_ALARM, newUri); } } private void setDefaultNotice(SongInfo info) { File dir = null; String what = "notifications"; Uri newUri = null; ContentValues values = new ContentValues(); boolean isRingTone = false; if (Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED)) { dir = new File(Environment.getExternalStorageDirectory(),what); } else { dir = context.getCacheDir(); } if (!dir.exists()) { dir.mkdirs(); } File file = new File(dir, info.getFileName()); if (!file.exists()) { try { file.createNewFile(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { InputStream inputStream = context.getResources() .openRawResource(info.getAudioResource()); OutputStream outputStream = new FileOutputStream(file); byte[] buffer = new byte[1024]; int length; while ((length = inputStream.read(buffer)) > 0) { outputStream.write(buffer, 0, length); } outputStream.flush(); outputStream.close(); inputStream.close(); } catch (Exception e) { // TODO: handle exception } } context.sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE)); String[] columns = { MediaStore.Audio.Media.DATA, MediaStore.Audio.Media._ID, MediaStore.Audio.Media.IS_NOTIFICATION }; Cursor cursor = context.getContentResolver().query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, columns, MediaStore.Audio.Media.DATA+" = '"+file.getAbsolutePath()+"'",null, null); if (cursor!=null) { int idColumn = cursor.getColumnIndex(MediaStore.Audio.Media._ID); int fileColumn = cursor.getColumnIndex(MediaStore.Audio.Media.DATA); int ringtoneColumn = cursor.getColumnIndex(MediaStore.Audio.Media.IS_NOTIFICATION); while (cursor.moveToNext()) { String audioFilePath = cursor.getString(fileColumn); if (cursor.getString(ringtoneColumn)!=null && cursor.getString(ringtoneColumn).equals("1")) { Uri hasUri = MediaStore.Audio.Media.getContentUriForPath(audioFilePath); newUri = Uri.withAppendedPath(hasUri, cursor.getString(idColumn)); isRingTone = true; } } cursor.close(); } if (isRingTone) { RingtoneManager.setActualDefaultRingtoneUri(context, RingtoneManager.TYPE_NOTIFICATION, newUri); }else{ values.put(MediaStore.MediaColumns.DATA, file.getAbsolutePath()); values.put(MediaStore.MediaColumns.TITLE, info.getName()); values.put(MediaStore.MediaColumns.SIZE, file.length()); values.put(MediaStore.MediaColumns.MIME_TYPE, "audio/mp3"); values.put(MediaStore.Audio.Media.IS_NOTIFICATION, true); newUri = context.getContentResolver().insert(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, values); RingtoneManager.setActualDefaultRingtoneUri(context, RingtoneManager.TYPE_NOTIFICATION, newUri); } } private void deleteRingtone(SongInfo info) { File dir = null; if (Environment.getExternalStorageState().equals( android.os.Environment.MEDIA_MOUNTED)) { dir = new File(Environment.getExternalStorageDirectory(), "Ringtones"); } else { dir = context.getCacheDir(); } if (!dir.exists()) { dir.mkdirs(); } Log.d(TAG, "dir:"+dir.getPath()); File file = new File(dir, info.getFileName()); Log.d(TAG, "file name:"+info.getFileName()); Uri uri = MediaStore.Audio.Media.getContentUriForPath(file .getAbsolutePath()); context.getContentResolver().delete( uri, MediaStore.MediaColumns.DATA + " = \"" + file.getAbsolutePath() + "\"", null); if (file.exists()) { file.delete(); } } OnRingtonePlay onRingtonePlay; /** * @param onRingtonePlay the onRingtonePlay to set */ public void setOnRingtonePlay(OnRingtonePlay onRingtonePlay) { this.onRingtonePlay = onRingtonePlay; } interface OnRingtonePlay{ public void onPlay(); } } > i Want to add a font to this "textView" holder.txtName = (TextView) view.findViewById(R.id.txtSongName); i tried this but it doesnt work for me // give the font path String fontPath = "font/myfont.otf"; TextView txtName = (TextView) findViewById(R.id.txtSongName); // get the font face Typeface tf = Typeface.createFromAsset((AssetManager) getAssets(), fontPath); // Apply the font txtName.setTypeface(tf); // holder = (ViewHolder) view.getTag(); and thank you very Much :)
0debug
How do i comapre string and substrings out of DataTables? : I have a DataTable with 1 column and a List of DataTables with 2 columns each.<br> I want to compare the Value of the DataTable with the first 6 digits of the Value of each DataTable in the List row by row. <br> <br>**This is my Code:** for(int fs = 0; fs < dataTable.Rows.Count; fs++) { for(int fs2 = 0; fs < dataTableList.Count; fs2++) { for(int fs3 = 0; fs3 < dataTableList[fs2].Rows.Count; fs3++) { if(dataTable.Rows[fs]["columnName"].ToString().Equals(dataTableList[fs2].Rows[fs3]["otherColumnName"].ToString().Substring(0,6))) { //do sth. } } } } When the programm reaches `if(dataTable.Rows[fs]["columnName"].ToString().Equals(dataTableList[fs2].Rows[fs3]["otherColumnName"].ToString().Substring(0,6)))` it stops and i get an `System.ArgumentOutOfRangeException` error.<br> Does anyody know what iam doing wrong? <br>When i MessageBox the substring its working btw...<br><br>with kind regards: speschel
0debug
How can Solve HTTP to HTTPS issue on HTML Template : <p>I have a site <a href="http://template.helloxpart.com/picasso/picasso/home_default.html" rel="nofollow noreferrer">http://template.helloxpart.com/picasso/picasso/home_default.html</a>, how can i secure this from http:// to https:// ?</p>
0debug
int ff_j2k_init_component(Jpeg2000Component *comp, Jpeg2000CodingStyle *codsty, Jpeg2000QuantStyle *qntsty, int cbps, int dx, int dy) { int reslevelno, bandno, gbandno = 0, ret, i, j, csize = 1; if (ret=ff_j2k_dwt_init(&comp->dwt, comp->coord, codsty->nreslevels-1, codsty->transform)) return ret; for (i = 0; i < 2; i++) csize *= comp->coord[i][1] - comp->coord[i][0]; comp->data = av_malloc(csize * sizeof(int)); if (!comp->data) return AVERROR(ENOMEM); comp->reslevel = av_malloc(codsty->nreslevels * sizeof(Jpeg2000ResLevel)); if (!comp->reslevel) return AVERROR(ENOMEM); for (reslevelno = 0; reslevelno < codsty->nreslevels; reslevelno++) { int declvl = codsty->nreslevels - reslevelno; Jpeg2000ResLevel *reslevel = comp->reslevel + reslevelno; for (i = 0; i < 2; i++) for (j = 0; j < 2; j++) reslevel->coord[i][j] = ff_jpeg2000_ceildivpow2(comp->coord[i][j], declvl - 1); if (reslevelno == 0) reslevel->nbands = 1; else reslevel->nbands = 3; if (reslevel->coord[0][1] == reslevel->coord[0][0]) reslevel->num_precincts_x = 0; else reslevel->num_precincts_x = ff_jpeg2000_ceildivpow2(reslevel->coord[0][1], codsty->log2_prec_width) - (reslevel->coord[0][0] >> codsty->log2_prec_width); if (reslevel->coord[1][1] == reslevel->coord[1][0]) reslevel->num_precincts_y = 0; else reslevel->num_precincts_y = ff_jpeg2000_ceildivpow2(reslevel->coord[1][1], codsty->log2_prec_height) - (reslevel->coord[1][0] >> codsty->log2_prec_height); reslevel->band = av_malloc(reslevel->nbands * sizeof(Jpeg2000Band)); if (!reslevel->band) return AVERROR(ENOMEM); for (bandno = 0; bandno < reslevel->nbands; bandno++, gbandno++) { Jpeg2000Band *band = reslevel->band + bandno; int cblkno, precx, precy, precno; int x0, y0, x1, y1; int xi0, yi0, xi1, yi1; int cblkperprecw, cblkperprech; if (qntsty->quantsty != JPEG2000_QSTY_NONE) { static const uint8_t lut_gain[2][4] = {{0, 0, 0, 0}, {0, 1, 1, 2}}; int numbps; numbps = cbps + lut_gain[codsty->transform][bandno + reslevelno>0]; band->stepsize = SHL(2048 + qntsty->mant[gbandno], 2 + numbps - qntsty->expn[gbandno]); } else band->stepsize = 1 << 13; if (reslevelno == 0) { band->codeblock_width = 1 << FFMIN(codsty->log2_cblk_width, codsty->log2_prec_width-1); band->codeblock_height = 1 << FFMIN(codsty->log2_cblk_height, codsty->log2_prec_height-1); for (i = 0; i < 2; i++) for (j = 0; j < 2; j++) band->coord[i][j] = ff_jpeg2000_ceildivpow2(comp->coord[i][j], declvl-1); } else{ band->codeblock_width = 1 << FFMIN(codsty->log2_cblk_width, codsty->log2_prec_width); band->codeblock_height = 1 << FFMIN(codsty->log2_cblk_height, codsty->log2_prec_height); for (i = 0; i < 2; i++) for (j = 0; j < 2; j++) band->coord[i][j] = ff_jpeg2000_ceildivpow2(comp->coord[i][j] - (((bandno+1>>i)&1) << declvl-1), declvl); } band->cblknx = ff_jpeg2000_ceildiv(band->coord[0][1], band->codeblock_width) - band->coord[0][0] / band->codeblock_width; band->cblkny = ff_jpeg2000_ceildiv(band->coord[1][1], band->codeblock_height) - band->coord[1][0] / band->codeblock_height; for (j = 0; j < 2; j++) band->coord[0][j] = ff_jpeg2000_ceildiv(band->coord[0][j], dx); for (j = 0; j < 2; j++) band->coord[1][j] = ff_jpeg2000_ceildiv(band->coord[1][j], dy); band->cblknx = ff_jpeg2000_ceildiv(band->cblknx, dx); band->cblkny = ff_jpeg2000_ceildiv(band->cblkny, dy); band->cblk = av_malloc(sizeof(Jpeg2000Cblk) * band->cblknx * band->cblkny); if (!band->cblk) return AVERROR(ENOMEM); band->prec = av_malloc(sizeof(Jpeg2000Cblk) * reslevel->num_precincts_x * reslevel->num_precincts_y); if (!band->prec) return AVERROR(ENOMEM); for (cblkno = 0; cblkno < band->cblknx * band->cblkny; cblkno++) { Jpeg2000Cblk *cblk = band->cblk + cblkno; cblk->zero = 0; cblk->lblock = 3; cblk->length = 0; cblk->lengthinc = 0; cblk->npasses = 0; } y0 = band->coord[1][0]; y1 = ((band->coord[1][0] + (1<<codsty->log2_prec_height)) & ~((1<<codsty->log2_prec_height)-1)) - y0; yi0 = 0; yi1 = ff_jpeg2000_ceildivpow2(y1 - y0, codsty->log2_cblk_height) << codsty->log2_cblk_height; yi1 = FFMIN(yi1, band->cblkny); cblkperprech = 1<<(codsty->log2_prec_height - codsty->log2_cblk_height); for (precy = 0, precno = 0; precy < reslevel->num_precincts_y; precy++) { for (precx = 0; precx < reslevel->num_precincts_x; precx++, precno++) { band->prec[precno].yi0 = yi0; band->prec[precno].yi1 = yi1; } yi1 += cblkperprech; yi0 = yi1 - cblkperprech; yi1 = FFMIN(yi1, band->cblkny); } x0 = band->coord[0][0]; x1 = ((band->coord[0][0] + (1<<codsty->log2_prec_width)) & ~((1<<codsty->log2_prec_width)-1)) - x0; xi0 = 0; xi1 = ff_jpeg2000_ceildivpow2(x1 - x0, codsty->log2_cblk_width) << codsty->log2_cblk_width; xi1 = FFMIN(xi1, band->cblknx); cblkperprecw = 1<<(codsty->log2_prec_width - codsty->log2_cblk_width); for (precx = 0, precno = 0; precx < reslevel->num_precincts_x; precx++) { for (precy = 0; precy < reslevel->num_precincts_y; precy++, precno = 0) { Jpeg2000Prec *prec = band->prec + precno; prec->xi0 = xi0; prec->xi1 = xi1; prec->cblkincl = ff_j2k_tag_tree_init(prec->xi1 - prec->xi0, prec->yi1 - prec->yi0); prec->zerobits = ff_j2k_tag_tree_init(prec->xi1 - prec->xi0, prec->yi1 - prec->yi0); if (!prec->cblkincl || !prec->zerobits) return AVERROR(ENOMEM); } xi1 += cblkperprecw; xi0 = xi1 - cblkperprecw; xi1 = FFMIN(xi1, band->cblknx); } } } return 0; }
1threat
Azure CDN + Asp.net MVC Cloud Service compression for bundles not working : <p>I am using Azure CDN which is pointing to my Azure Cloud Service. I have enabled bundling for my JS and CSS files, and in BundleConfig I have set <code>bundles.UseCdn = true</code>. </p> <p>Everything is working fine, except that JS &amp; CSS bundles returned via CDN are not compressed. If I am not using CDN, bundles are returned compressed (I can see that Content-Encoding is gzip).</p> <p>I have enabled compression on my CDN as you can see in pic below:</p> <p><a href="https://i.stack.imgur.com/S8Xsz.png" rel="noreferrer"><img src="https://i.stack.imgur.com/S8Xsz.png" alt="enter image description here"></a></p> <p>And in my ASP.net MVC web.config compression is also enabled, and it looks like this:</p> <pre><code> &lt;urlCompression doStaticCompression="true" doDynamicCompression="true" /&gt; &lt;httpCompression&gt; &lt;dynamicTypes&gt; &lt;clear/&gt; &lt;add mimeType="text/*" enabled="true" /&gt; &lt;add mimeType="message/*" enabled="true" /&gt; &lt;add mimeType="application/x-javascript" enabled="true" /&gt; &lt;add mimeType="text/javascript" enabled="true" /&gt; &lt;add mimeType="text/css" enabled="true" /&gt; &lt;add mimeType="application/json" enabled="true" /&gt; &lt;!-- HERE --&gt; &lt;add mimeType="image/svg+xml" enabled="true" /&gt; &lt;add mimeType="image/png" enabled="true" /&gt; &lt;add mimeType="image/jpg" enabled="true" /&gt; &lt;add mimeType="image/jpeg" enabled="true" /&gt; &lt;add mimeType="application/font-woff2" enabled="true" /&gt; &lt;add mimeType="application/x-font-ttf" enabled="true" /&gt; &lt;add mimeType="application/octet-stream" enabled="true" /&gt; &lt;!-- HERE --&gt; &lt;add mimeType="*/*" enabled="false" /&gt; &lt;/dynamicTypes&gt; &lt;staticTypes&gt; &lt;clear/&gt; &lt;add mimeType="text/*" enabled="true" /&gt; &lt;add mimeType="message/*" enabled="true" /&gt; &lt;add mimeType="application/x-javascript" enabled="true" /&gt; &lt;add mimeType="text/javascript" enabled="true" /&gt; &lt;add mimeType="text/css" enabled="true" /&gt; &lt;add mimeType="application/atom+xml" enabled="true" /&gt; &lt;add mimeType="application/xaml+xml" enabled="true" /&gt; &lt;!-- HERE --&gt; &lt;add mimeType="image/png" enabled="true" /&gt; &lt;add mimeType="image/jpg" enabled="true" /&gt; &lt;add mimeType="image/jpeg" enabled="true" /&gt; &lt;add mimeType="application/font-woff2" enabled="true" /&gt; &lt;add mimeType="application/x-font-ttf" enabled="true" /&gt; &lt;add mimeType="application/octet-stream" enabled="true" /&gt; &lt;!-- HERE --&gt; &lt;add mimeType="*/*" enabled="false" /&gt; &lt;/staticTypes&gt; &lt;/httpCompression&gt; </code></pre> <p>Interestingly, for same CDN profile (but other endpoint) pictures do have Content-Encoding: gzip, so it seems that compression works fine on CDN also.</p> <p><a href="https://stackoverflow.com/a/10434390/1284262">This SO answer</a> suggested adding smth. like <code>&amp;group=smth.js</code> at the end of CDN URL, but that din't help.</p> <p>So what am I doing wrong? </p>
0debug
how to get month from date in javascript? : <p>I'm trying to get month from my date variable.</p> <pre><code>date=Date.now(); console.log(date); &gt;&gt;2019-12-04T08:55:48.972Z </code></pre> <p>I want to get the month from this date but when I'm using getMonth(), I'm getting error.</p> <pre><code>console.log(date.getMonth()); error:- getMonth is not a function </code></pre>
0debug
React-virtualized, List is Flickkering/lagging when scrolling : <p>I am experiencing some problem when i scroll through my list. Also notice the huge space at the bottom. See video : <a href="https://vimeo.com/215349521" rel="noreferrer">https://vimeo.com/215349521</a></p> <p>As far as i can see, im not making any huge mistakes. But i do belive the problem is due to the CellMeasurer.</p> <p>Chrome version: 58.0.3029.81</p> <pre><code>class PromotionList extends Component { constructor(props) { super(props); this.cache = new CellMeasurerCache({ defaultHeight: 100, fixedWidth: true, }); this.rowRenderer = this.rowRenderer.bind(this); } componentWillMount() { this.props.fetchPromotionsIfNeeded(); } rowRenderer({ index, parent }) { const { promotions } = this.props; const data = promotions.list[index]; return ( &lt;CellMeasurer cache={this.cache} columnIndex={0} key={uuid.v1()} parent={parent} rowIndex={index} &gt; &lt;BlobItem key={uuid.v1()} type={BlobTypes.promotion} data={data} onClick={this.props.onItemClick} index={index} /&gt; &lt;/CellMeasurer&gt; ); } render() { const { promotions, previewSize } = this.props; return ( &lt;List height={300} width={previewSize.width} rowCount={promotions.list.length} deferredMeasurementCache={this.cache} rowHeight={this.cache.rowHeight} rowRenderer={this.rowRenderer} className="blobList" /&gt; ); } } </code></pre>
0debug
static int ssi_sd_init(SSISlave *d) { DeviceState *dev = DEVICE(d); ssi_sd_state *s = FROM_SSI_SLAVE(ssi_sd_state, d); DriveInfo *dinfo; s->mode = SSI_SD_CMD; dinfo = drive_get_next(IF_SD); s->sd = sd_init(dinfo ? blk_bs(blk_by_legacy_dinfo(dinfo)) : NULL, true); if (s->sd == NULL) { return -1; } register_savevm(dev, "ssi_sd", -1, 1, ssi_sd_save, ssi_sd_load, s); return 0; }
1threat
How can I reuse a double in C# : Hello I am trying to write a code which will ask a question the client dims for a crate once the client replies it will ask if you need to add more crate, if the client says yes how would I repeat the same code? I think I need top add a loop here but I'm not sure how to reuse the same variable. Thank you for your help. Ed Console.WriteLine("Please enter the crate Length for your incoming shipment: "); double l = new double(); l = double.Parse(Console.ReadLine()); Console.WriteLine("Enter the crate Width for your incoming shipment: "); double w = new double(); w = double.Parse(Console.ReadLine()); Console.WriteLine("Enter the crate Height for your incoming shipmet"); double h = new double(); h = double.Parse(Console.ReadLine()); double totalDims = new double(); totalDims = l * w * h; double volKg = new double(); volKg = totalDims / 366; Console.WriteLine("Your total Vol Kg is {0:0.00}", +volKg); Console.ReadLine(); Console.Write("Are there any additional crates y/n? "); char a = new char(); a = char.Parse(Console.ReadLine()); char y = default(char); while (a == y) { //Crate Dimensions Entered Console.WriteLine("Please enter the crate Length for your incoming shipment: "); double l = new double(); l = double.Parse(Console.ReadLine()); Console.WriteLine("Enter the crate Width for your incoming shipment: "); double w = new double(); w = double.Parse(Console.ReadLine()); Console.WriteLine("Enter the crate Height for your incoming shipmet"); double h = new double(); h = double.Parse(Console.ReadLine()); } }
0debug
static int nvdec_vp9_start_frame(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size) { VP9SharedContext *h = avctx->priv_data; const AVPixFmtDescriptor *pixdesc = av_pix_fmt_desc_get(avctx->sw_pix_fmt); NVDECContext *ctx = avctx->internal->hwaccel_priv_data; CUVIDPICPARAMS *pp = &ctx->pic_params; CUVIDVP9PICPARAMS *ppc = &pp->CodecSpecific.vp9; FrameDecodeData *fdd; NVDECFrame *cf; AVFrame *cur_frame = h->frames[CUR_FRAME].tf.f; int ret, i; ret = ff_nvdec_start_frame(avctx, cur_frame); if (ret < 0) return ret; fdd = (FrameDecodeData*)cur_frame->private_ref->data; cf = (NVDECFrame*)fdd->hwaccel_priv; *pp = (CUVIDPICPARAMS) { .PicWidthInMbs = (cur_frame->width + 15) / 16, .FrameHeightInMbs = (cur_frame->height + 15) / 16, .CurrPicIdx = cf->idx, .CodecSpecific.vp9 = { .width = cur_frame->width, .height = cur_frame->height, .LastRefIdx = get_ref_idx(h->refs[h->h.refidx[0]].f), .GoldenRefIdx = get_ref_idx(h->refs[h->h.refidx[1]].f), .AltRefIdx = get_ref_idx(h->refs[h->h.refidx[2]].f), .profile = h->h.profile, .frameContextIdx = h->h.framectxid, .frameType = !h->h.keyframe, .showFrame = !h->h.invisible, .errorResilient = h->h.errorres, .frameParallelDecoding = h->h.parallelmode, .subSamplingX = pixdesc->log2_chroma_w, .subSamplingY = pixdesc->log2_chroma_h, .intraOnly = h->h.intraonly, .allow_high_precision_mv = h->h.keyframe ? 0 : h->h.highprecisionmvs, .refreshEntropyProbs = h->h.refreshctx, .bitDepthMinus8Luma = pixdesc->comp[0].depth - 8, .bitDepthMinus8Chroma = pixdesc->comp[1].depth - 8, .loopFilterLevel = h->h.filter.level, .loopFilterSharpness = h->h.filter.sharpness, .modeRefLfEnabled = h->h.lf_delta.enabled, .log2_tile_columns = h->h.tiling.log2_tile_cols, .log2_tile_rows = h->h.tiling.log2_tile_rows, .segmentEnabled = h->h.segmentation.enabled, .segmentMapUpdate = h->h.segmentation.update_map, .segmentMapTemporalUpdate = h->h.segmentation.temporal, .segmentFeatureMode = h->h.segmentation.absolute_vals, .qpYAc = h->h.yac_qi, .qpYDc = h->h.ydc_qdelta, .qpChDc = h->h.uvdc_qdelta, .qpChAc = h->h.uvac_qdelta, .resetFrameContext = h->h.resetctx, .mcomp_filter_type = h->h.filtermode ^ (h->h.filtermode <= 1), .frameTagSize = h->h.uncompressed_header_size, .offsetToDctParts = h->h.compressed_header_size, .refFrameSignBias[0] = 0, } }; for (i = 0; i < 2; i++) ppc->mbModeLfDelta[i] = h->h.lf_delta.mode[i]; for (i = 0; i < 4; i++) ppc->mbRefLfDelta[i] = h->h.lf_delta.ref[i]; for (i = 0; i < 7; i++) ppc->mb_segment_tree_probs[i] = h->h.segmentation.prob[i]; for (i = 0; i < 3; i++) { ppc->activeRefIdx[i] = h->h.refidx[i]; ppc->segment_pred_probs[i] = h->h.segmentation.pred_prob[i]; ppc->refFrameSignBias[i + 1] = h->h.signbias[i]; } for (i = 0; i < 8; i++) { ppc->segmentFeatureEnable[i][0] = h->h.segmentation.feat[i].q_enabled; ppc->segmentFeatureEnable[i][1] = h->h.segmentation.feat[i].lf_enabled; ppc->segmentFeatureEnable[i][2] = h->h.segmentation.feat[i].ref_enabled; ppc->segmentFeatureEnable[i][3] = h->h.segmentation.feat[i].skip_enabled; ppc->segmentFeatureData[i][0] = h->h.segmentation.feat[i].q_val; ppc->segmentFeatureData[i][1] = h->h.segmentation.feat[i].lf_val; ppc->segmentFeatureData[i][2] = h->h.segmentation.feat[i].ref_val; ppc->segmentFeatureData[i][3] = 0; } switch (avctx->colorspace) { default: case AVCOL_SPC_UNSPECIFIED: ppc->colorSpace = 0; break; case AVCOL_SPC_BT470BG: ppc->colorSpace = 1; break; case AVCOL_SPC_BT709: ppc->colorSpace = 2; break; case AVCOL_SPC_SMPTE170M: ppc->colorSpace = 3; break; case AVCOL_SPC_SMPTE240M: ppc->colorSpace = 4; break; case AVCOL_SPC_BT2020_NCL: ppc->colorSpace = 5; break; case AVCOL_SPC_RESERVED: ppc->colorSpace = 6; break; case AVCOL_SPC_RGB: ppc->colorSpace = 7; break; } return 0; }
1threat
Chart.js axes label font size : <p>In chart.js how can I set the set the font size for just the x axis labels without touching global config?</p> <p>I've already tried setting the 'scaleFontSize' option my options object. I've also tried setting:</p> <pre><code>{ ... scales: { xAxes: [{ scaleFontSize: 40 ... }] } } </code></pre>
0debug
Get all keys from GroupBy object in Pandas : <p>I'm looking for a way to get a list of all the keys in a GroupBy object, but I can't seem to find one via the docs nor through Google. </p> <p>There is definitely a way to access the groups through their keys, like so:</p> <pre><code>df_gb = df.groupby(['EmployeeNumber']) df_gb.get_group(key) </code></pre> <p>...so I figure there's a way to access a list (or the like) of the keys in a GroupBy object. I'm looking for something like this:</p> <pre><code>df_gb.keys Out: [1234, 2356, 6894, 9492] </code></pre> <p>I figure I could just loop through the GroupBy object and get the keys that way, but I think there's got to be a better way.</p>
0debug
Best practice of retrieving params and queryParams in Angular 2 : <p>I'm trying to understand the way of creating a route, with some information in it's URL parameters. </p> <p>This is my route (app.routes.ts):</p> <pre><code>{path: 'results/:id', component: MyResultsComponent}, </code></pre> <p>This is how I navigate to the route :</p> <pre><code>goToResultsPage(query: string) { this.router.navigate(['results', query], { queryParams: { pageSize: 20 } });} </code></pre> <p>As you can see, I've also a query parameter. I was wondering, what is the best and cleanest way to retrieve this in my <code>MyResultsComponent</code>. Right now I've kind of a nested <code>subscribe</code> structure:</p> <pre><code>ngOnInit() { this.route .params .subscribe(params =&gt; { this.query = params['id']; this.route .queryParams .subscribe(queryParams =&gt; { this.offset = queryParams['pageSize']; #find entries this.entryService.findEntries(this.query, this.pageSize); }); }); } </code></pre> <p>Afterwards, I want to pass this parameters to my <code>EntryService</code>, which returns the found entries.</p>
0debug
static int cmos_get_fd_drive_type(FloppyDriveType fd0) { int val; switch (fd0) { case FLOPPY_DRIVE_TYPE_144: val = 4; break; case FLOPPY_DRIVE_TYPE_288: val = 5; break; case FLOPPY_DRIVE_TYPE_120: val = 2; break; case FLOPPY_DRIVE_TYPE_NONE: default: val = 0; break; } return val; }
1threat
Response to preflight request doesn't pass access control check (Angular2) : <p>I am getting below error on call to REST Web API in Asp.net.</p> <p><strong>XMLHttpRequest cannot load <a href="http://localhost:54859/api/PostData" rel="noreferrer">http://localhost:54859/api/PostData</a>. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin '<a href="http://localhost:3000" rel="noreferrer">http://localhost:3000</a>' is therefore not allowed access.</strong></p> <p>I am using Angular2 as Front end. In the back end, I have added following codes to enable CORS in WEB API.</p> <pre><code> var corsAttr = new EnableCorsAttribute("*", "*", "*"); config.EnableCors(corsAttr); </code></pre> <p>Everything works fine for Http get request,but the same not for Http Post request.</p> <p>Any help would be appreciable </p> <p>Thanks in advance!</p>
0debug
static void rtas_ibm_read_pci_config(sPAPREnvironment *spapr, uint32_t token, uint32_t nargs, target_ulong args, uint32_t nret, target_ulong rets) { uint32_t val, size, addr; uint64_t buid = ((uint64_t)rtas_ld(args, 1) << 32) | rtas_ld(args, 2); PCIDevice *dev = find_dev(spapr, buid, rtas_ld(args, 0)); if (!dev) { rtas_st(rets, 0, -1); return; } size = rtas_ld(args, 3); addr = rtas_pci_cfgaddr(rtas_ld(args, 0)); val = pci_default_read_config(dev, addr, size); rtas_st(rets, 0, 0); rtas_st(rets, 1, val); }
1threat
How can i get the data from Swift based IBOutlet UITextFiled? : @IBOutlet var firstName:UITextField? @IBOutlet var lastName:UITextField? let string = firstName!.text print(string) The output is like as bellow, Optional("fhh") How can i get the data without optional text and double quotes.
0debug
query results and loop them into a table by catagory : I'm trying to query my products table; +-------------------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------------------+--------------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | name | varchar(50) | NO | | NULL | | | make | varchar(50) | NO | | NULL | | | email | varchar(200) | NO | | NULL | | | catagory | longtext | NO | | NULL | | +-------------------+--------------+------+-----+---------+----------------+ i want to query the database and echo the results in a table like so, i want it to echo the catagory name then echo all the <td></td> which will contain the name, make and some other details etc.. I want to show it like so; Catagory: name name name name ------------------------------------- Catagory: name name name name ------------------------------------- Catagory: name name name name ------------------------------------- Catagory: name name name name ------------------------------------- where each name is a different product in the product table. Not sure where too look and what to search for.
0debug
Given a current list node how do I insert an item, x, correctly after the node referenced by current? : <p>The question is given a current (a reference to a list node), which statement may insert an item x correctly after the node referenced by current?</p> <p>My options are:</p> <pre><code>a. current = new ListNode(x, current); b. current.next = new ListNode( x, current.next); c. current.next() = new ListNode(x, current); d. current.next() = new ListNode(x, current.next); e. current = new ListNode(x, current.next); f. current.next = new ListNode ( x, current); g. none of the above. </code></pre> <p>I believe the right answer is b because it is referencing current.next and placing x in the current.next position. Please let me know if you think my answer is correct. </p>
0debug
how can I change the shape of scroller with JS : <p>I've got confused how other front end developers can they change the scroller shape of web page in order to make it good look how can I use JS to make this happens? </p>
0debug
what language is this file writen in? : I have been assigned a task to retrieve information from files that were processed from raw mass spectrophotometry data (file.mzML). These files have just ".data" as extension and when I open them, I cannot recognize the language and therefore I cannot load them into R and work on them. The files with the .data extension are contained in this folder: ftp://ftp.pride.ebi.ac.uk/pride/data/archive/2015/11/PXD000299/ Could someone take a look at any of the files.data and tell me the language is in (e.g. F010439)? Thank you very much!
0debug
like dislike button system jquery : Hi I want to have a like and dislike button and when one of them is clicked, it will change a colour to red but when I click both, both like and dislike icons can be red when only one of them should be red. How do I fix it? and I'm wondering if I can write the code shorter by using CSS and .hasClass, .removeClass and .addClass in Jquery OR toggle. below is the Jquery code that I've written $('#Like').on({ 'click': function() { if($('#Like').attr('src') == 'images/Like.png') { $('#Like').attr('src','images/Liked.png'); $('#Dislike').attr('src') == 'images/Dislike.png'); } else { $('#Like').attr('src','images/Like.png'); } } }); $('#Dislike').on({ 'click': function() { if($('#Dislike').attr('src') == 'images/Dislike.png') { $('#Dislike').attr('src','images/Disliked.png'); $('#heartLike').attr('src') == 'images/Like.png'); } else { $('#Dislike').attr('src','images/Dislike.png'); } } }); Here, #like and #dislike are the original like and dislike icons. Like.png and Dislike.png are the images without colour and Liked.png and Disiked.png are the images with filled in red colour.
0debug
int ffurl_get_short_seek(URLContext *h) { if (!h->prot->url_get_short_seek) return AVERROR(ENOSYS); return h->prot->url_get_short_seek(h); }
1threat
An unhandled exception of type 'System.Net.WebException' occurred in System.dll i dont know how to fix it : MY CODE I keep getting this error i have no idea how to fix it 1 hour still no solutions =============================================== InitializeComponent(); pictureBox1.BackColor = Color.Transparent; } private void pictureBox1_Click(object sender, EventArgs e) { } private void button1_Click(object sender, EventArgs e) { using (WebClient client = new WebClient()) { client.DownloadFile("http://itzyzex.comlu.com/itzy.PNG", @"C:\Users\fatih\Desktop\stuff"); } } // WebClient Client = new WebClient(); //Client.DownloadFile("https://cdn.meme.am/instances/60569499.jpg", @"C:\Users\fatih\Desktop"); } }
0debug
unable to blink led 3 times in arduiono program : I want to run the loop for three times to blink the led 3 times in arduino programme. How to run the loop for 3 times and exit from the loop.how to use return statement in loop? int LedPin = 13; int Loops = 1; void setup() { pinMode(LedPin, OUTPUT); } void loop() { digitalWrite(13, LOW); Loops = Loops + 1; if ( Loops < 3 ) { digitalWrite(13, HIGH); delay(2000); } else { digitalWrite(13, LOW); exit(0); } }
0debug
static int xen_init(MachineState *ms) { xen_xc = xen_xc_interface_open(0, 0, 0); if (xen_xc == XC_HANDLER_INITIAL_VALUE) { xen_be_printf(NULL, 0, "can't open xen interface\n"); qemu_add_vm_change_state_handler(xen_change_state_handler, NULL); global_state_set_optional(); savevm_skip_configuration(); savevm_skip_section_footers(); return 0;
1threat
How to use the code returned from Cognito to get AWS credentials? : <p>Right now, I'm struggling to understand AWS Cognito so maybe someone could help me out. I set a domain to serve Cognito's hosted UI for my User Pool like what's described <a href="http://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-pools-ux.html" rel="noreferrer">here</a>. So when I go to <code>https://&lt;my-domain&gt;.auth.us-east-1.amazoncognito.com/login?response_type=code&amp;client_id=&lt;MY_POOL_CLIENT_ID&gt;&amp;redirect_uri=https://localhost:8080</code> I get a login page where my users can login to my app with Google. That part is working great.</p> <p>I confused about what to do with the code that is returned from that page once my user logs in. So once I get redirected to Google and authorize the application to view my information, I get redirected back to one of my URLs with a code in the query params. Right now I'm redirecting to localhost, so the redirect URL look like this:</p> <p><code>https://localhost:8080/?code=XXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX</code></p> <p>What exactly is this code? Also, how do I use it to get access to AWS resources for my user?</p>
0debug
Spark: split one pairRDD into two : I have pairRDD like (1, JOHN SMITH) (2, JACK SMITH) And I would like to split them to: (1, JOHN) (1, SMITH) (2, JACK) (2, SMITH) I tried flatMapValues, but not quite right in the details
0debug
Some questions about implementation of nullptr in Effective C++ by Scott Meyers, Second Edition? : <pre><code>const // It is a const object... class nullptr_t { public: template&lt;class T&gt; inline operator T*() const // convertible to any type of null non-member pointer... { return 0; } template&lt;class C, class T&gt; inline operator T C::*() const // or any type of null member pointer... { return 0; } private: void operator&amp;() const; // Can't take address of nullptr } nullptr = {}; </code></pre> <ol> <li><code>operator T*() const</code> and <code>operator T C::*() const</code> are already defined in class, so it can inline automatically. So, why add <code>inline</code> again? </li> <li>why <code>void operator&amp;() const;</code>, not<code>void operator&amp;() = delete</code>? </li> <li>what does <code>nullptr = {};</code> mean? </li> </ol>
0debug
Multiple Repositories for the Same Entity in Spring Data Rest : <p>Is it possible to publish two different repositories for the same JPA entity with Spring Data Rest? I gave the two repositories different paths and rel-names, but only one of the two is available as REST endpoint. The point why I'm having two repositories is, that one of them is an excerpt, showing only the basic fields of an entity.</p>
0debug
Android 6 EditText.setError not working correctly : <p>I have upgraded to android 6 and seeing some strange things when trying to set validation for some editTexts. I am using android-saripaar for validation:</p> <pre><code>@Email(messageResId = R.string.error_email) private EditText email; @Password(min = 6, scheme = Password.Scheme.ALPHA_NUMERIC_MIXED_CASE_SYMBOLS) private EditText password; @ConfirmPassword private EditText repassword; @NotEmpty(messageResId = R.string.error_name) private EditText firstname; @NotEmpty(messageResId = R.string.error_name) private EditText lastname; private Validator mValidator; </code></pre> <p>For some reason the email, password, confirm password are not showing the error message on the popup, while the last and first name are fine</p> <p><a href="https://i.stack.imgur.com/BcHbk.png" rel="noreferrer"><img src="https://i.stack.imgur.com/BcHbk.png" alt="enter image description here"></a></p> <p>I have tried without the library and the same issue occurred. Using editText.setError("Some Message") This did not happen prior to android 6 and was working fine on 5.</p> <p>Anybody experienced similar to this? if so how did you fix it?</p>
0debug
angularjs does not allow you to create ul recursively within li : How can I create that deep structure with ng-repeat? I'm having problems with tags that are automatically closed in this directive. can anybody help me? <ul> <li>A <ul> <li>B <ul> <li>C <ul><li>D</li></ul> </li> </ul> </li> </ul> </li> </ul> here is the json code. {"obj":[{"code":"0","name":"A"},{"code":"1","name":"B"}, {"code":"2","name":"C"},{"code":"3","name":"D"}]} Thanks in advance.
0debug
Unable to reset element to a vlaue of 0 : <p>I have the following function here that I am using to reset the value attribute of some buttons to 0:</p> <pre><code>function resetAll() { var getAllButttons = document.getElementsByClassName("click-button"); for (i = 0; i &lt; getAllButtons.length; i++) { getAllButtons[i].value == 0; } } </code></pre> <p>The function is not doing what I want it to and i'm a bit stuck as to where i've gone wrong.. </p>
0debug
How to read data from csv file and store it in the database ? Spring Boot : <p>For example I have an entity of Users consisting of username,phonenumber and address. I want to read all these fields from a csv file and store it in the respective table in the database?</p> <p>Can any one Help me by describing how to do that? Or is there any documentation on how to do that?</p>
0debug
I run into trouble when i make my java Procedures to package,i do not know why? : <p><a href="http://i.stack.imgur.com/fOBsN.jpg" rel="nofollow">i use hipster to builder my procedures,but it is wrong</a></p> <p>i use hipster to builder my procedures ,but it tell me this Problem</p>
0debug
static void qmp_output_end_struct(Visitor *v, void **obj) { QmpOutputVisitor *qov = to_qov(v); QObject *value = qmp_output_pop(qov, obj); assert(qobject_type(value) == QTYPE_QDICT); }
1threat
i am writing code in angularjs using html . in this minlength and maxlength validations are not working .here my code : html code : <input type="text" id="healthcomplaint" ng-model="userDetails.healthcomplaint" style="color:#4a5665;" class="form-control" name="healthcomplaint" ng-required="true" ng-minlength="3" ng-maxlength="120" ng-pattern="/^[a-zA-Z0-9\s\[\]\.,\_\/\-#']*$/" tabindex="8"> <span class="ng-hide error_txt" ng-show="submitted && info.healthcomplaint.$error.required">Please enter health complaint.</span> <span class="ng-hide error_txt" ng-show="info.healthcomplaint.$error.minlength">health complaint should have at least 3 characters.</span> <span class="ng-hide error_txt" ng-show="info.healthcomplaint.$error.maxlength">health complaint should not exceed 120 characters.</span>
0debug
Iterating through keys of Immutable Map in React : <p>What is a good practice for handling iteration through an Immutable.js Map object? This works: </p> <pre><code>{stocks.map((stock,key)=&gt;{ return ( &lt;h3&gt;{key}&lt;/h3&gt; ) })} </code></pre> <p>but gives the warning in the console "warning.js:45 Warning: Using Maps as children is not yet fully supported. It is an experimental feature that might be removed. Convert it to a sequence / iterable of keyed ReactElements instead."</p> <p>This has been discussed before, and this link suggests some strategies <a href="https://github.com/facebook/immutable-js/issues/667">https://github.com/facebook/immutable-js/issues/667</a> but they seem clunky to me. Like:</p> <pre><code>posts.entrySeq().map(o =&gt; &lt;Post value={o[1]} key={o[0]} /&gt; ) </code></pre> <p>works but is clunky feeling. Is there a more natural way of doing this?</p>
0debug
static int thp_probe(AVProbeData *p) { if (p->buf_size < 4) return 0; if (AV_RL32(p->buf) == MKTAG('T', 'H', 'P', '\0')) return AVPROBE_SCORE_MAX; else return 0; }
1threat
How to use a union using linq? : <p>I have two tables:</p> <p>1) Customer Table 2) Custmer Email Table</p> <p><a href="https://i.stack.imgur.com/DsTEk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DsTEk.png" alt="enter image description here"></a> <a href="https://i.stack.imgur.com/sbRH5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sbRH5.png" alt="enter image description here"></a></p> <p>what i want to get both email ids which have customerId=4. can I make a union and get my desire result like: **</p> <pre><code>cusromerId:4 EmailId: sumit.printzone@gmail.com vinod.printzone@gmail.com </code></pre> <p>**</p>
0debug
When should i use `==` vs `===` vs `isequal` : <p>I see that julia has 3 different ways to do equality.</p> <p><code>==</code>, <code>===</code>, and <code>isequal</code></p> <p>Which should I use, and when?</p>
0debug
PHP (Laravel) loop - every n-th entry : <p>Haven't found what I was looking for specifically. I only find questions where people break the loop, in my case I do not want to break it. I simply want to insert something special every n-th time.</p> <p>I have a database with projects, and I want to display them in a grid. I simply loop every row from the database to display it in the grid. But now the client wants to show a customer's quote though out the grid. Mor specifically like this: show 3 projects, place 1 quote, repeat...</p> <p><a href="https://i.stack.imgur.com/ct4ak.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ct4ak.jpg" alt="enter image description here"></a></p> <p>Obviously the 4th item in the loop is very different from the other ones, so I cannot store them in the samen database table. The 'projects' have image and title (among many other things), the quote simply has a name and body. </p> <p>How would you guys make this as dynamic as possible? Since the client has a CMS where he can add new projects. </p>
0debug
JS code doesn't work after combining two lines of code into a shorter one : This is original code: h1tag= document.getElementById("myHeading"); h1tag.addEventListener("mouseover", ()=>{h1tag.style.backgroundColor="blue"}); After combining: h1tag= document.getElementById("myHeading").addEventListener("mouseover", ()=>{h1tag.style.backgroundColor="blue"});
0debug
How to animate toggling of table rows? : <p>I want to animate the appearance and disappearance of table rows.</p> <p>First of all I tried using a CSS <em>transition</em>, but it did nothing due to the change of the <code>display</code> property.</p> <p>So I used an <em>animation</em>, which works as expected.</p> <p>The problem is, <strong>the full height of the row is reserved when the animation begins</strong>. See the snippet below for an illustration of the problem: Row 3 is pushed down straight away, before the animation begins.</p> <p><strong>How can I animate the height of the row progressively, so that it only takes as much space as needed?</strong></p> <p>And as a bonus:</p> <ul> <li>it should <strong>not require a fixed height</strong> for rows</li> <li>it should appear as a translation, rather than a scaling; it should look like it's <strong>sliding from the bottom of the row above it</strong></li> <li>it should be <strong>bidirectional</strong> (do the opposite when I hide it)</li> </ul> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>$('button').on('click', function() { $('tr:nth-child(2)').toggleClass('active'); });</code></pre> <pre class="snippet-code-css lang-css prettyprint-override"><code>@keyframes anim { 0% { transform: scaleY(0); } 100% { transform: scaleY(1); } } tr { background: #eee; border-bottom: 1px solid #ddd; display: none; transform-origin: top; } tr.active { display: table-row; animation: anim 0.5s ease; } td { padding: 10px; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js"&gt;&lt;/script&gt; &lt;button type="button"&gt;Toggle&lt;/button&gt; &lt;table&gt; &lt;tbody&gt; &lt;tr class="active"&gt; &lt;td&gt;Row 1&lt;/td&gt; &lt;td&gt;...&lt;/td&gt; &lt;td&gt;...&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Row 2&lt;/td&gt; &lt;td&gt;...&lt;/td&gt; &lt;td&gt;...&lt;/td&gt; &lt;/tr&gt; &lt;tr class="active"&gt; &lt;td&gt;Row 3&lt;/td&gt; &lt;td&gt;...&lt;/td&gt; &lt;td&gt;...&lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt;</code></pre> </div> </div> </p>
0debug
I need to get information from json : Here is the result of: var_dump($response): "is_claimed": false, "rating": 4.5, "mobile_url": "http://m.yelp.com/biz/filbert-steps-san-francisco?utm_campaign=yelp_api\u0026utm_medium=api_v2_business\u0026utm_source=NUQkLT4j4VnC6ZR7LI-VWA", "rating_img_url": "https://s3-media2.fl.yelpcdn.com/assets/2/www/img/99493c12711e/ico/stars/v1/stars_4_half.png", "review_count": 208
0debug
Finding sum of geometric sequence with modulo 10^9+7 : The problem is given as: Output the answer of (A^1+A^2+A^3+...+A^K) modulo 1,000,000,007, where 1≤ A, K ≤ 10^9, and A and K must be an integer. I am trying to write a program to compute the above question. I have tried using the formula for geometric sequence, then applying the modulo on the answer. Since the results must be an integer as well, finding modulo inverse is not required.
0debug
Angular 2 - 404 traceur not found : <p>I've followed the starting guide and expanded a little upon for a previous angular 2 version. I've updated my revision and changed everything accordingly. When I am running the web server I now receive the error 404 for traceur... <a href="https://i.stack.imgur.com/hHyvT.png"><img src="https://i.stack.imgur.com/hHyvT.png" alt="Error 404 for traceur"></a></p> <p>Here is my project structure: <a href="https://i.stack.imgur.com/PoHLC.png"><img src="https://i.stack.imgur.com/PoHLC.png" alt="Project structure"></a></p> <p>Relevant files : </p> <p>Index.html:</p> <pre><code> &lt;html&gt; &lt;head&gt; &lt;title&gt;Kinepolis HR-tool&lt;/title&gt; &lt;base href="./"&gt; &lt;meta charset="utf-8"&gt; &lt;meta http-equiv="X-UA-Compatible" content="IE=edge"&gt; &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt; &lt;meta name="description" content="Kinepolis HR tool"&gt; &lt;meta name="author" content="Jeffrey Devloo!"&gt; &lt;link rel="stylesheet" type="text/css" href="assets/css/bootstrap.min.css" /&gt; &lt;!-- CSS for PrimeUI --&gt; &lt;!-- 1. Load libraries --&gt; &lt;!-- Polyfill(s) for older browsers --&gt; &lt;script src="node_modules/es6-shim/es6-shim.min.js"&gt;&lt;/script&gt; &lt;script src="node_modules/zone.js/dist/zone.js"&gt;&lt;/script&gt; &lt;script src="node_modules/reflect-metadata/Reflect.js"&gt;&lt;/script&gt; &lt;script src="node_modules/systemjs/dist/system.src.js"&gt;&lt;/script&gt; &lt;!-- 2. Configure SystemJS --&gt; &lt;script src="systemjs.config.js"&gt;&lt;/script&gt; &lt;script&gt; System.import('app').catch(function(err){ console.error(err); }); &lt;/script&gt; &lt;/head&gt; &lt;!-- 3. Display the application --&gt; &lt;body&gt; &lt;my-app&gt;Loading...&lt;/my-app&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>systemjs.config.js</p> <pre><code>(function(global) { // map tells the System loader where to look for things var map = { 'app': 'app', // 'dist', 'rxjs': 'node_modules/rxjs', 'angular2-in-memory-web-api': 'node_modules/angular2-in-memory-web-api', '@angular': 'node_modules/@angular', }; // packages tells the System loader how to load when no filename and/or no extension var packages = { 'app': { main: 'main.js', defaultExtension: 'js' }, 'rxjs': { defaultExtension: 'js' }, 'angular2-in-memory-web-api': { defaultExtension: 'js' }, }; var packageNames = [ '@angular/common', '@angular/compiler', '@angular/core', '@angular/http', '@angular/platform-browser', '@angular/platform-browser-dynamic', '@angular/router', '@angular/router-deprecated', '@angular/testing', '@angular/upgrade', ]; // add package entries for angular packages in the form '@angular/common': { main: 'index.js', defaultExtension: 'js' } packageNames.forEach(function(pkgName) { packages[pkgName] = { main: 'index.js', defaultExtension: 'js' }; }); var config = { map: map, packages: packages } // filterSystemConfig - index.html's chance to modify config before we register it. if (global.filterSystemConfig) { global.filterSystemConfig(config); } System.config(config); })(this); </code></pre> <p>tsconfig.json</p> <pre><code> { "compilerOptions": { "target": "es5", "module": "commonjs", "moduleResolution": "node", "sourceMap": true, "emitDecoratorMetadata": true, "experimentalDecorators": true, "removeComments": false, "noImplicitAny": false }, "exclude": [ "node_modules", "typings/main", "typings/main.d.ts" ] } </code></pre> <p>A possible issue could be <a href="https://i.stack.imgur.com/4zFPw.png"><img src="https://i.stack.imgur.com/4zFPw.png" alt="enter image description here"></a> this is boycotting my progress.</p>
0debug
static void pc_dimm_plug(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { int slot; HotplugHandlerClass *hhc; Error *local_err = NULL; PCMachineState *pcms = PC_MACHINE(hotplug_dev); MachineState *machine = MACHINE(hotplug_dev); PCDIMMDevice *dimm = PC_DIMM(dev); PCDIMMDeviceClass *ddc = PC_DIMM_GET_CLASS(dimm); MemoryRegion *mr = ddc->get_memory_region(dimm); uint64_t addr = object_property_get_int(OBJECT(dimm), PC_DIMM_ADDR_PROP, &local_err); if (local_err) { addr = pc_dimm_get_free_addr(pcms->hotplug_memory_base, memory_region_size(&pcms->hotplug_memory), !addr ? NULL : &addr, memory_region_size(mr), &local_err); if (local_err) { object_property_set_int(OBJECT(dev), addr, PC_DIMM_ADDR_PROP, &local_err); if (local_err) { trace_mhp_pc_dimm_assigned_address(addr); slot = object_property_get_int(OBJECT(dev), PC_DIMM_SLOT_PROP, &local_err); if (local_err) { slot = pc_dimm_get_free_slot(slot == PC_DIMM_UNASSIGNED_SLOT ? NULL : &slot, machine->ram_slots, &local_err); if (local_err) { object_property_set_int(OBJECT(dev), slot, PC_DIMM_SLOT_PROP, &local_err); if (local_err) { trace_mhp_pc_dimm_assigned_slot(slot); if (!pcms->acpi_dev) { error_setg(&local_err, "memory hotplug is not enabled: missing acpi device"); memory_region_add_subregion(&pcms->hotplug_memory, addr - pcms->hotplug_memory_base, mr); vmstate_register_ram(mr, dev); hhc = HOTPLUG_HANDLER_GET_CLASS(pcms->acpi_dev); hhc->plug(HOTPLUG_HANDLER(pcms->acpi_dev), dev, &local_err); out: error_propagate(errp, local_err);
1threat
static av_cold int atrac1_decode_init(AVCodecContext *avctx) { AT1Ctx *q = avctx->priv_data; avctx->sample_fmt = AV_SAMPLE_FMT_FLT; if (avctx->channels < 1 || avctx->channels > AT1_MAX_CHANNELS) { av_log(avctx, AV_LOG_ERROR, "Unsupported number of channels: %d\n", avctx->channels); return AVERROR(EINVAL); } q->channels = avctx->channels; if (avctx->channels == 2) { q->out_samples[0] = av_malloc(2 * AT1_SU_SAMPLES * sizeof(*q->out_samples[0])); q->out_samples[1] = q->out_samples[0] + AT1_SU_SAMPLES; if (!q->out_samples[0]) { av_freep(&q->out_samples[0]); return AVERROR(ENOMEM); } } ff_mdct_init(&q->mdct_ctx[0], 6, 1, -1.0/ (1 << 15)); ff_mdct_init(&q->mdct_ctx[1], 8, 1, -1.0/ (1 << 15)); ff_mdct_init(&q->mdct_ctx[2], 9, 1, -1.0/ (1 << 15)); ff_init_ff_sine_windows(5); atrac_generate_tables(); dsputil_init(&q->dsp, avctx); ff_fmt_convert_init(&q->fmt_conv, avctx); q->bands[0] = q->low; q->bands[1] = q->mid; q->bands[2] = q->high; q->SUs[0].spectrum[0] = q->SUs[0].spec1; q->SUs[0].spectrum[1] = q->SUs[0].spec2; q->SUs[1].spectrum[0] = q->SUs[1].spec1; q->SUs[1].spectrum[1] = q->SUs[1].spec2; return 0; }
1threat
C: How to perform accurate floating-point operations? : <p>I am well aware that <code>0.1+0.2 != 0.3</code> because of precision errors. However I need it to be equal to 0.3.</p> <p>My solution would be to :</p> <ul> <li>Declare an <code>add</code> function that returns the correct <code>double</code>.</li> <li>Inside this function, add the two numbers then round to the 13th digit.</li> </ul> <p>This would work for 0.49999999999999994 and 0.30000000000000004.</p> <p>How would I implement such a rounding function? Is there another way?</p>
0debug
What is difference between waitForAngularEnabled and browser.ignoreSynchronization in protractor? : <p>What is browser.ignoreSynchronization?</p> <pre><code>/** * If true, Protractor will not attempt to synchronize with the page before * performing actions. This can be harmful because Protractor will not wait * until $timeouts and $http calls have been processed, which can cause * tests to become flaky. This should be used only when necessary, such as * when a page continuously polls an API using $timeout. * * @type {boolean} */ </code></pre> <p>&amp; <a href="http://www.protractortest.org/#/timeouts#how-to-disable-waiting-for-angular" rel="noreferrer">waitForAngularEnabled</a> Both looks same. Is there any specific thing that can achieve by one and not by other?</p>
0debug
Using WireMock with SOAP Web Services in Java : <p>I am totally new to <a href="http://wiremock.org/index.html" rel="noreferrer">WireMock</a>.</p> <p>Until now, I have been using mock responses using SOAPUI. My use case is simple:</p> <p>Just firing SOAP XML requests to different endpoints (<a href="http://localhost:9001/endpoint1" rel="noreferrer">http://localhost:9001/endpoint1</a>) and getting canned XML response back. But MockWrire has to be deployed as a standalone service onto a dedicated server which will act a central location from where mock responses will be served.</p> <p>Just wanted some starting suggestions. As I can see WireMock is more suitable towards REST web services. So my doubts are:</p> <p>1) Do I need to deploy it to a java web server or container to act as always running standalone service. I read that you can just spin off by using</p> <pre><code>java -jar mockwire.jar --port [port_number] </code></pre> <p>2) Do I need to use MockWire APIs? Do I need to make classes for my use case? In my case, requests will be triggered via JUnit test cases for mocking.</p> <p>3) How do I achieve simple URL pattern matching? As stated above, I just need simple mocking i.e get response when request is made to <a href="http://localhost:9001/endpoint1" rel="noreferrer">http://localhost:9001/endpoint1</a></p> <p>4) Is there a better/easier framework for my usecase? I read about Mockable but it has restrictions for 3 team members and demo domain in free tier.</p>
0debug
static uint64_t grlib_apbuart_read(void *opaque, target_phys_addr_t addr, unsigned size) { UART *uart = opaque; addr &= 0xff; switch (addr) { case DATA_OFFSET: case DATA_OFFSET + 3: return uart_pop(uart); case STATUS_OFFSET: return uart->status; case CONTROL_OFFSET: return uart->control; case SCALER_OFFSET: return 0; default: trace_grlib_apbuart_readl_unknown(addr); return 0; } }
1threat
static int filter_frame(AVFilterLink *inlink, AVFrame *in) { AVFilterContext *ctx = inlink->dst; HDCDContext *s = ctx->priv; AVFilterLink *outlink = ctx->outputs[0]; AVFrame *out; const int16_t *in_data; int32_t *out_data; int n, c; int detect, packets, pe_packets; out = ff_get_audio_buffer(outlink, in->nb_samples); if (!out) { av_frame_free(&in); return AVERROR(ENOMEM); } av_frame_copy_props(out, in); out->format = outlink->format; in_data = (int16_t*)in->data[0]; out_data = (int32_t*)out->data[0]; for (n = 0; n < in->nb_samples * in->channels; n++) { out_data[n] = in_data[n]; } detect = 0; packets = 0; pe_packets = 0; s->det_errors = 0; for (c = 0; c < inlink->channels; c++) { hdcd_state_t *state = &s->state[c]; hdcd_process(s, state, out_data + c, in->nb_samples, out->channels); if (state->sustain) detect++; packets += state->code_counterA + state->code_counterB; pe_packets += state->count_peak_extend; s->uses_transient_filter |= !!state->count_transient_filter; s->max_gain_adjustment = FFMIN(s->max_gain_adjustment, GAINTOFLOAT(state->max_gain)); s->det_errors += state->code_counterA_almost + state->code_counterB_checkfails + state->code_counterC_unmatched; } if (pe_packets) { if (packets == pe_packets) s->peak_extend = HDCD_PE_PERMANENT; else s->peak_extend = HDCD_PE_INTERMITTENT; } else { s->peak_extend = HDCD_PE_NEVER; } if (detect == inlink->channels) s->hdcd_detected = 1; s->sample_count += in->nb_samples * in->channels; av_frame_free(&in); return ff_filter_frame(outlink, out); }
1threat
Postgres jsonb 'NOT contains' operator : <p>I'm experimenting with postgres <code>jsonb</code> column types, and so far so good. One common query I'm using is like this: </p> <pre><code>select count(*) from jsonbtest WHERE attributes @&gt; '{"City":"Mesa"}'; </code></pre> <p>How do I reverse that? Is there a different operator or is it simply used as </p> <pre><code>select count(*) from jsonbtest WHERE NOT attributes @&gt; '{"City":"Mesa"}'; </code></pre>
0debug
void virtio_queue_notify(VirtIODevice *vdev, int n) { if (n < VIRTIO_PCI_QUEUE_MAX && vdev->vq[n].vring.desc) { trace_virtio_queue_notify(vdev, n, &vdev->vq[n]); vdev->vq[n].handle_output(vdev, &vdev->vq[n]); } }
1threat
i need help incorporating my two codes1 : i want to use these two functions! and ask the user for their name! after their name is given, it will be printed out in a sentence. i want to ask user to chose between both "games", and i want to call the correct function in an if statement. # coding=utf-8 import time import calendar from random import randint def mygame(): """ Guessing game! """ playing = True num = randint(1, 100) guesses = 0 print("Welcome to my Game") print("Would you like to play?") print("Yes or No") Yes = "Yes" No = "No" x = input() if x == Yes: print("Welcome to my game!") while playing: print("Guess a number between 1 and 100") guess = int(input("What is your guess?!")) if guess > 100 or guess < 1: invalid = True while invalid: print("Invalid number guessed, Enter a new NUMBER, between 1 and 100") guess = int(input("What is your guess?!")) guesses += 1 if 100 >= guess >= 1: invalid = False guesses -= 1 guesses += 1 print(guess) if guess == num: print("You Guessed the number correctly, it only took you " + str(guesses)) playing = False elif guess > num: print("Your guess was too high!, TRY AGAIN!") else: print("Your guess was too low, TRY AGAIN!") if x == No: print("Goodbye!") quit() def calendar1(): """ This prints out calendar for November of 2016 """ cal = calendar.month(2016, 11) print("What is your name?") name = input() print("Hello %s, I have two options for you today!" % name) localTime = time.asctime(time.localtime(time.time())) # This is formatted time! print(localTime)
0debug
I got an error about something having 'already been defined in game.obj'. What do I do? : <p>While I was working with SDL2 in Visual Studio 2019, I came across a few errors:</p> <pre><code> 1&gt;Source.obj : error LNK2005: "struct SDL_Window * game::gWindow" (?gWindow@game@@3PAUSDL_Window@@A) already defined in game.obj 1&gt;Source.obj : error LNK2005: "struct SDL_Surface * game::gScreenSurface" (?gScreenSurface@game@@3PAUSDL_Surface@@A) already defined in game.obj 1&gt;Source.obj : error LNK2005: "struct SDL_Surface * game::gImage" (?gImage@game@@3PAUSDL_Surface@@A) already defined in game.obj </code></pre> <p>I looked up how to fix it to no avail. I tried using externs, changing my game.h file but nothing worked. Just as some background info, I am trying to make a game engine type thing using SDL2 to help me in the future with game development. I would like to keep as much code as possible, not removing too much.</p> <p>Here is my code: Source.cpp</p> <pre><code> #include &lt;SDL.h&gt; #include "game.h" #include &lt;stdio.h&gt; int main(int argc, char* args[]) { if (!game::init()) { // SDL failed it initialize printf("error"); } else { // SDL was able to initialize if (!game::loadMedia()) { // Could not load media printf("error"); } else { // Could load media SDL_BlitSurface(game::gImage, NULL, game::gScreenSurface, NULL); } } return 0; } </code></pre> <p>game.cpp</p> <pre><code>#include &lt;SDL.h&gt; #include "game.h" #include &lt;stdio.h&gt; namespace game { //functions bool init() { bool success = true; if (SDL_Init(SDL_INIT_VIDEO) &lt; 0) { printf("SDL failed to initialize.\n"); success = false; } else { gWindow = SDL_CreateWindow( "SDL Window (;", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN ); if (gWindow == NULL) { printf("Window could not be created! SDL_Error: %s\n", SDL_GetError()); success = false; } else { //Get window surface gScreenSurface = SDL_GetWindowSurface(gWindow); } } return success; } bool loadMedia() { // Loading success flag bool success = true; // File name of image const char* fileName = "mario.bmp"; // Load splash image gImage = SDL_LoadBMP(fileName); if (gImage == NULL) { printf("Unable to load image '%s'! SDL Error: %s\n", fileName, SDL_GetError()); success = false; } return success; } } </code></pre> <p>and game.h</p> <pre><code>#ifndef _GAME_H namespace game { SDL_Window* gWindow; SDL_Surface* gScreenSurface; SDL_Surface* gImage; const int SCREEN_WIDTH = 640; const int SCREEN_HEIGHT = 480; bool init(); bool loadMedia(); } #endif </code></pre> <p>Thanks in advance!</p>
0debug
How do I connect my python spyder with github? : <p>Is there any way to connect python spyder with github?</p> <p>I manage my R scripts via github, because R provides with interfaces that enables users to commit, pull and push, but I wonder if there is same(or similar) system in python(x,y) spyder.</p> <p>I want to manage my python scripts with github, not just locally editing my codes and manually write change logs on my hand every time...</p>
0debug
static void qed_read_backing_file(BDRVQEDState *s, uint64_t pos, QEMUIOVector *qiov, BlockDriverCompletionFunc *cb, void *opaque) { uint64_t backing_length = 0; size_t size; if (s->bs->backing_hd) { int64_t l = bdrv_getlength(s->bs->backing_hd); if (l < 0) { cb(opaque, l); return; } backing_length = l; } if (pos >= backing_length || pos + qiov->size > backing_length) { qemu_iovec_memset(qiov, 0, 0, qiov->size); } if (pos >= backing_length) { cb(opaque, 0); return; } size = MIN((uint64_t)backing_length - pos, qiov->size); BLKDBG_EVENT(s->bs->file, BLKDBG_READ_BACKING_AIO); bdrv_aio_readv(s->bs->backing_hd, pos / BDRV_SECTOR_SIZE, qiov, size / BDRV_SECTOR_SIZE, cb, opaque); }
1threat
void ssi_register_slave(SSISlaveInfo *info) { assert(info->qdev.size >= sizeof(SSISlave)); info->qdev.init = ssi_slave_init; info->qdev.bus_type = BUS_TYPE_SSI; qdev_register(&info->qdev); }
1threat
av_cold void ff_dcadsp_init_x86(DCADSPContext *s) { int cpu_flags = av_get_cpu_flags(); if (EXTERNAL_SSE(cpu_flags)) { #if ARCH_X86_32 s->int8x8_fmul_int32 = ff_int8x8_fmul_int32_sse; #endif s->lfe_fir[0] = ff_dca_lfe_fir0_sse; s->lfe_fir[1] = ff_dca_lfe_fir1_sse; } if (EXTERNAL_SSE2(cpu_flags)) { s->int8x8_fmul_int32 = ff_int8x8_fmul_int32_sse2; } if (EXTERNAL_SSE4(cpu_flags)) { s->int8x8_fmul_int32 = ff_int8x8_fmul_int32_sse4; } }
1threat
Why typeof NULL is return udefined? : >Why `typeof NULL` is return `udefined` while `typeof null` return `object` ? Check this snippet <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-js --> console.log(typeof NULL)// undefined console.log(typeof null)// object <!-- end snippet -->
0debug
static void add_pid_to_pmt(MpegTSContext *ts, unsigned int programid, unsigned int pid) { int i; struct Program *p = NULL; for(i=0; i<ts->nb_prg; i++) { if(ts->prg[i].id == programid) { p = &ts->prg[i]; break; } } if(!p) return; if(p->nb_pids >= MAX_PIDS_PER_PROGRAM) return; p->pids[p->nb_pids++] = pid; }
1threat
void cpu_x86_interrupt(CPUX86State *s) { s->interrupt_request = 1; }
1threat
Scala: drop elements from list based on position of elements : In Scala, what would be the right way of selecting elements of a list based on the position of two elements? Suppose I have the list below and I would like to select all the elements between 2 and 7, including them (note: not greater than/smaller than, but the elements that come after 2 and before 7 in the list): ``` scala> val l = List(1, 14, 2, 17, 35, 9, 12, 7, 9, 40) l: List[Int] = List(1, 14, 2, 17, 35, 9, 12, 7, 9, 40) scala> def someMethod(l: List[Int], from: Int, to: Int) : List[Int] = { | // some code here | } someMethod: (l: List[Int], from: Int, to: Int)List[Int] scala> someMethod(l, 2, 7) res0: List[Int] = List(2, 17, 35, 9, 12, 7) ```
0debug
Warning: session_destroy(): Trying to destroy uninitialized session[session_start() used] : <p>i know my code is very beginner because i am just started php. so sorry at beginning</p> <p>I already read stack other questions and answers about</p> <p><strong>Warning: session_destroy(): Trying to destroy uninitialized session</strong></p> <p>all answers just mentioned that i need to use <strong><em>session_start()</em></strong> before using </p> <p><strong><em>session_destroy();</em></strong></p> <p>but they are not explaining why this warning occurs even i already used <strong><em>session_start()</em></strong> i am just trying to login then dashboard page appears where user can click on logout button to logout</p> <p>whole application is working fine only problem is when i click on logout button in dashboard.php it go to logout page and show warning which above mentioned</p> <p>login.php</p> <pre><code>&lt;?php session_start(); } ?&gt; &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Login Page&lt;/title&gt; &lt;link rel="stylesheet" type="text/css" href="style.css"&gt; &lt;/head&gt; &lt;body&gt; &lt;div class="header"&gt; &lt;h1 align="center"&gt;Login&lt;/h1&gt; &lt;/div&gt; orm action="" method="post"&gt; &lt;table align="center"&gt; &lt;tr&gt; &lt;td align="right"&gt;&lt;input type="email" name="email" placeholder="Email" required&gt;&lt;/td&gt; &lt;td class="s1"&gt;*&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td align="right"&gt;&lt;input type="password" name="pass" placeholder="Password" pattern="(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,12}" title="Must contain at least one number and one uppercase and lowercase letter, and at least 8 or more characters" required&gt;&lt;/td&gt; &lt;td class="s1"&gt;*&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td align="right"&gt;&lt;input type="submit" value="Login"&gt;&lt;td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;p align="center"&gt;&lt;strong&gt;Or&lt;/strong&gt;&lt;/p&gt; &lt;p align="center"&gt;Create New acount &lt;strong&gt;&lt;input type="button" value="Sign Up" onclick="location.href='sign_up.php'"&gt;&lt;/strong&gt;&lt;/p&gt; &lt;br&gt; &lt;br&gt; &lt;br&gt; &lt;br&gt; &lt;br&gt; &lt;div class="footer"&gt; &lt;p&gt;&lt;span class="s1"&gt;*&lt;/span&gt; indicates mandatory feild&lt;p&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; &lt;?php require 'connection.php'; // connection if($_SERVER['REQUEST_METHOD'] === 'POST') { $email = $_POST['email']; $pass = $_POST['pass']; // getting username from database and storing into session variable /// $sql =mysqli_query($conn,"SELECT name FROM users WHERE email='$email'"); $sql1 = mysqli_fetch_assoc($sql); $user_name = $sql1['name']; // setting session variables $_SESSION['user_name']= $cookie_name; $_SESSION['timeout']=time(); // check email exists or not $query=mysqli_query($conn,"SELECT email FROM users WHERE email='$email'"); if(mysqli_num_rows($query) &gt; 0) { //check email and password correct or not $query1=mysqli_query($conn,"SELECT email, password FROM users WHERE email='$email' AND password='$pass'"); if(mysqli_num_rows($query1) &gt; 0) { // login success header("location:dashboard.php"); // ----&gt; alternative way to redirect to dashboard.php /*echo "&lt;script type='text/javascript'&gt; window.location.href = 'dashboard.php' &lt;/script&gt;";*/ } else { // incorrect password echo "&lt;p align='center' style='color:#ff6262'&gt;your password is incorrect!&lt;br&gt;Please try again&lt;/p&gt;"; } } else { // email not exist echo "&lt;p align='center' style='color:#ff6262'&gt;&lt;b&gt;Email you are entering does not exist in our database&lt;br&gt;&lt;/b&gt;&lt;/p&gt;"; } } ?&gt; </code></pre> <p>dashboard.php</p> <pre><code>&lt;?php session_start(); ?&gt; &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt; &lt;?php require 'connection.php'; echo $_SESSION['user_name']; ?&gt; &lt;/title&gt; &lt;link rel="stylesheet" type="text/css" href="style.css"&gt; &lt;/head&gt; &lt;body&gt; &lt;div class="header"&gt; &lt;h1 align="center"&gt;&lt;?php echo "Welcome: ".ucfirst($_SESSION['user_name']); ?&gt;&lt;/h1&gt; &lt;/div&gt; &lt;table&gt; &lt;tr&gt; &lt;td align="right"&gt;Change User Name:&lt;/td&gt;&lt;td&gt;&lt;input type="button" onclick="location.href='user.php'" value="click here"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td align="right"&gt;Change Password:&lt;/td&gt;&lt;td&gt;&lt;input type="button" onclick="location.href='pass.php'" value="click here"&gt;&lt;/td&gt; &lt;/tr colspan="2"&gt; &lt;tr&gt;&lt;td align="right"&gt;&lt;input type="button" value="Logout" onclick="location.href='logout.php'"&gt;&lt;/td&gt;&lt;/tr&gt; &lt;/table&gt; &lt;/body&gt; &lt;/html&gt; &lt;?php if (isset($_SESSION['timeout']) &amp;&amp; (time() - $_SESSION['timeout'] &gt; 60)) { session_unset(); // unset $_SESSION variable for the run-time session_destroy(); // destroy session data in storage header("location:logout.php"); } $_SESSION['timeout'] = time(); ?&gt; </code></pre> <p>logout.php</p> <pre><code>&lt;?php session_start(); ?&gt; &lt;?php session_unset(); if(!session_unset()) { echo "session not unset"; } else { echo "session unset"; } session_destroy(); if(!session_destroy()) { echo "session not destroyed"; } else { echo "session destroyed"; } //header(location:login.php); ?&gt; </code></pre> <p>some other suggest me to use cookies but i don't know how to relate cookies with session anyone who can help.</p>
0debug
Difference between namespaces and blueprints in flask-restful and flask : <p>I am unable to understand the what purpose does blueprints and namespaces serve in web app. I read the documentation but cannot figure it out exactly.<br> It would be really helpful for me if you give a simple explanation with example for each case.<br> Thanks!</p>
0debug
Cloud functions for firebase finished with status: 'timeout' : <p>Function gets executed without errors. I am getting the status</p> <blockquote> <p>Function execution took 60004 ms, finished with status: 'timeout'</p> </blockquote> <p>I am not sure what the issue is. Everything in my function looks good to me. I also noticed functions sometimes take several seconds to update database and sometimes it is instantly. Is it normal that execution times varies from instantly to couple second? Should execution times be instantly?</p> <pre><code>exports.countproposals = functions.database.ref("/proposals/{jobid}/{propid}").onWrite((event) =&gt; { const jobid = event.params.jobid; const userId = event.params.propid; const userRef = admin.database().ref(`users/${userId}/proposals/sent`); if (event.data.exists() &amp;&amp; !event.data.previous.exists()) { userRef.child(jobid).set({ timestamp: admin.database.ServerValue.TIMESTAMP }); } else if (!event.data.exists() &amp;&amp; event.data.previous.exists()) { userRef.child(jobid).remove(); } const collectionRef = admin.database().ref(`/jobs/${jobid}`); const countRef = collectionRef.child("proposals"); return countRef.transaction(current =&gt; { if (event.data.exists() &amp;&amp; !event.data.previous.exists()) { return (current || 0) + 1; } else if (!event.data.exists() &amp;&amp; event.data.previous.exists()) { return (current || 0) - 1; } }); }); </code></pre>
0debug
How to install cryptography on ubuntu? : <p>My ubuntu is 14.04 LTS.</p> <p>When I install cryptography, the error is:</p> <pre><code>Installing egg-scripts. uses namespace packages but the distribution does not require setuptools. Getting distribution for 'cryptography==0.2.1'. no previously-included directories found matching 'documentation/_build' zip_safe flag not set; analyzing archive contents... six: module references __path__ Installed /tmp/easy_install-oUz7ei/cryptography-0.2.1/.eggs/six-1.10.0-py2.7.egg Searching for cffi&gt;=0.8 Reading https://pypi.python.org/simple/cffi/ Best match: cffi 1.5.0 Downloading https://pypi.python.org/packages/source/c/cffi/cffi-1.5.0.tar.gz#md5=dec8441e67880494ee881305059af656 Processing cffi-1.5.0.tar.gz Writing /tmp/easy_install-oUz7ei/cryptography-0.2.1/temp/easy_install-Yf2Yl3/cffi-1.5.0/setup.cfg Running cffi-1.5.0/setup.py -q bdist_egg --dist-dir /tmp/easy_install-oUz7ei/cryptography-0.2.1/temp/easy_install-Yf2Yl3/cffi-1.5.0/egg-dist-tmp-A2kjMD c/_cffi_backend.c:15:17: fatal error: ffi.h: No such file or directory #include &lt;ffi.h&gt; ^ compilation terminated. error: Setup script exited with error: command 'x86_64-linux-gnu-gcc' failed with exit status 1 An error occurred when trying to install cryptography 0.2.1. Look above this message for any errors that were output by easy_install. While: Installing egg-scripts. Getting distribution for 'cryptography==0.2.1'. Error: Couldn't install: cryptography 0.2.1 </code></pre> <p>I don't know why it was failed. What is the reason. Is there something necessary when install it on ubuntu system?</p>
0debug
Algorithm to detect more than one sequence of 4 same letters horizontally, vertically or diagonally : I have been assigned a task to write an algorithm to detect if a given array of strings contains more than one sequence of 4 repeated letters horizontally, vertically or diagonally. They also asked me the most efficient way to do it. An input example would be something like this: `String[] input = {"ATGCGA","CAGTGC","TTATGT","AGAAGG","CCCCTA","TCACTG"};` but you guys can see it more clearly like a table here: A T G C G A C A G T G C T T A T G T A G A A G G C C C C T A T C A C T G This array contains 3 sequences with a repeated letter: AAAA is found diagonally CCCC is found horizontally GGGG is found vertically So, since there are more than 1 sequence found in this input example, the output should be true. I have an idea to solve this problem but my major issue is handling the diagonals, especially using an efficient way to do it since they expect to use this function in a high concurrency environment. I would be grateful for any help provided. It's ok if someone can't write the code, but at least some ideas to get the right approach to solve this problem. I am thankful already!
0debug
void palette8torgb24(const uint8_t *src, uint8_t *dst, long num_pixels, const uint8_t *palette) { long i; for(i=0; i<num_pixels; i++) { dst[0]= palette[ src[i]*4+2 ]; dst[1]= palette[ src[i]*4+1 ]; dst[2]= palette[ src[i]*4+0 ]; dst+= 3; } }
1threat
SCSIRequest *scsi_req_new(SCSIDevice *d, uint32_t tag, uint32_t lun, uint8_t *buf, void *hba_private) { SCSIBus *bus = DO_UPCAST(SCSIBus, qbus, d->qdev.parent_bus); SCSIRequest *req; SCSICommand cmd; if (scsi_req_parse(&cmd, d, buf) != 0) { trace_scsi_req_parse_bad(d->id, lun, tag, buf[0]); req = scsi_req_alloc(&reqops_invalid_opcode, d, tag, lun, hba_private); } else { trace_scsi_req_parsed(d->id, lun, tag, buf[0], cmd.mode, cmd.xfer); if (req->cmd.lba != -1) { trace_scsi_req_parsed_lba(d->id, lun, tag, buf[0], cmd.lba); } if ((d->unit_attention.key == UNIT_ATTENTION || bus->unit_attention.key == UNIT_ATTENTION) && (buf[0] != INQUIRY && buf[0] != REPORT_LUNS && buf[0] != GET_CONFIGURATION && buf[0] != GET_EVENT_STATUS_NOTIFICATION)) { req = scsi_req_alloc(&reqops_unit_attention, d, tag, lun, hba_private); } else if (lun != d->lun || buf[0] == REPORT_LUNS || buf[0] == REQUEST_SENSE) { req = scsi_req_alloc(&reqops_target_command, d, tag, lun, hba_private); } else { req = d->info->alloc_req(d, tag, lun, hba_private); } } req->cmd = cmd; switch (buf[0]) { case INQUIRY: trace_scsi_inquiry(d->id, lun, tag, cmd.buf[1], cmd.buf[2]); break; case TEST_UNIT_READY: trace_scsi_test_unit_ready(d->id, lun, tag); break; case REPORT_LUNS: trace_scsi_report_luns(d->id, lun, tag); break; case REQUEST_SENSE: trace_scsi_request_sense(d->id, lun, tag); break; default: break; } return req; }
1threat
More than one fragment with the name [spring_web] was found. This is not legal with relative ordering : <p>I have a spring boot application that works fine when I run it using the embedded server from Intellj. However, when I package it into .war file and deploy it on tomcat I get the following error:</p> <pre><code> org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/file-upload-0.0.1-SNAPSHOT]] at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:754) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:730) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734) at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:985) at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1857) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) Caused by: java.lang.IllegalArgumentException: More than one fragment with the name [spring_web] was found. This is not legal with relative ordering. See section 8.2.2 2c of the Servlet specification for details. Consider using absolute ordering. at org.apache.tomcat.util.descriptor.web.WebXml.orderWebFragments(WebXml.java:2200) at org.apache.tomcat.util.descriptor.web.WebXml.orderWebFragments(WebXml.java:2159) at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1124) at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:769) at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:299) at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:94) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5176) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) ... 10 more 21-Jan-2019 01:51:04.709 SEVERE [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Error deploying web application archive [C:\Users\dennismo\Dev\Projects\Production Prep\file-upload-module\webapps\file-upload-0.0.1-SNAPSHOT.war] java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/file-upload-0.0.1-SNAPSHOT]] at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:758) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:730) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734) at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:985) at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1857) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) </code></pre> <p>My project does not contain multiple web-fragment so I don't know what could be causing this problem.</p> <p>pom.xml</p> <pre><code>&lt;parent&gt; &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt; &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt; &lt;version&gt;2.1.0.RELEASE&lt;/version&gt; &lt;relativePath/&gt; &lt;!-- lookup parent from salaryPaymentRequestRepo --&gt; &lt;/parent&gt; &lt;properties&gt; &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt; &lt;project.reporting.outputEncoding&gt;UTF-8&lt;/project.reporting.outputEncoding&gt; &lt;java.version&gt;1.8&lt;/java.version&gt; &lt;akka.version&gt;2.5.17&lt;/akka.version&gt; &lt;/properties&gt; &lt;repositories&gt; &lt;repository&gt; &lt;id&gt;default&lt;/id&gt; &lt;url&gt;http://repo.maven.apache.org/maven2&lt;/url&gt; &lt;/repository&gt; &lt;/repositories&gt; &lt;dependencies&gt; &lt;dependency&gt; &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt; &lt;artifactId&gt;spring-boot-starter-thymeleaf&lt;/artifactId&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt; &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt; &lt;artifactId&gt;spring-boot-starter-data-jpa&lt;/artifactId&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt; &lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt; &lt;scope&gt;test&lt;/scope&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt; &lt;artifactId&gt;spring-boot-starter-tomcat&lt;/artifactId&gt; &lt;scope&gt;provided&lt;/scope&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;com.h2database&lt;/groupId&gt; &lt;artifactId&gt;h2&lt;/artifactId&gt; &lt;version&gt;1.4.197&lt;/version&gt; &lt;scope&gt;compile&lt;/scope&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;com.univocity&lt;/groupId&gt; &lt;artifactId&gt;univocity-parsers&lt;/artifactId&gt; &lt;version&gt;2.7.6&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.projectlombok&lt;/groupId&gt; &lt;artifactId&gt;lombok&lt;/artifactId&gt; &lt;optional&gt;true&lt;/optional&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;com.fasterxml.jackson.dataformat&lt;/groupId&gt; &lt;artifactId&gt;jackson-dataformat-xml&lt;/artifactId&gt; &lt;version&gt;2.9.0&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;com.google.guava&lt;/groupId&gt; &lt;artifactId&gt;guava&lt;/artifactId&gt; &lt;version&gt;26.0-jre&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.mockito&lt;/groupId&gt; &lt;artifactId&gt;mockito-core&lt;/artifactId&gt; &lt;version&gt;2.23.4&lt;/version&gt; &lt;scope&gt;test&lt;/scope&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;com.google.code.gson&lt;/groupId&gt; &lt;artifactId&gt;gson&lt;/artifactId&gt; &lt;version&gt;2.8.5&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;com.squareup.okhttp3&lt;/groupId&gt; &lt;artifactId&gt;okhttp&lt;/artifactId&gt; &lt;version&gt;3.11.0&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;ma.glasnost.orika&lt;/groupId&gt; &lt;artifactId&gt;orika-core&lt;/artifactId&gt; &lt;version&gt;1.4.2&lt;/version&gt;&lt;!-- or latest version --&gt; &lt;exclusions&gt; &lt;exclusion&gt; &lt;artifactId&gt;javassist&lt;/artifactId&gt; &lt;groupId&gt;org.javassist&lt;/groupId&gt; &lt;/exclusion&gt; &lt;/exclusions&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;com.typesafe.akka&lt;/groupId&gt; &lt;artifactId&gt;akka-actor_2.12&lt;/artifactId&gt; &lt;version&gt;${akka.version}&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;com.typesafe.akka&lt;/groupId&gt; &lt;artifactId&gt;akka-stream_2.12&lt;/artifactId&gt; &lt;version&gt;${akka.version}&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;com.typesafe.akka&lt;/groupId&gt; &lt;artifactId&gt;akka-persistence_2.12&lt;/artifactId&gt; &lt;version&gt;${akka.version}&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;com.typesafe.akka&lt;/groupId&gt; &lt;artifactId&gt;akka-testkit_2.12&lt;/artifactId&gt; &lt;version&gt;${akka.version}&lt;/version&gt; &lt;scope&gt;test&lt;/scope&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;com.oracle&lt;/groupId&gt; &lt;artifactId&gt;ojdbc7&lt;/artifactId&gt; &lt;version&gt;12.1.0.2&lt;/version&gt; &lt;scope&gt;system&lt;/scope&gt; &lt;systemPath&gt;${basedir}/src/main/resources/lib/ojdbc7-12.1.0.jar&lt;/systemPath&gt; &lt;/dependency&gt; &lt;/dependencies&gt; &lt;build&gt; &lt;plugins&gt; &lt;plugin&gt; &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt; &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt; &lt;/plugin&gt; &lt;/plugins&gt; &lt;/build&gt; </code></pre>
0debug
C++ How to pass serveral paramters to a thread? [HANDLE hThread] : <pre><code>HANDLE hThread = CreateThread(NULL, 0, ManageThread, (LPVOID)lParam, 0, NULL); WaitForSingleObject(hThread, INFINITE); </code></pre> <p>How can I pass serveral HANDLE param via lParam?</p> <p>I have to use serveral HANDLE variable on hThread.</p> <pre><code>DWORD WINAPI ManageThread(LPVOID lParam) { HANDLE hPingpong = ...; //From lParam; HANDLE hVolley = ...; //From lParam; ... HANDLE hBasket = ...; //From lParam; ... return GetLastError(); } </code></pre> <p>I would appreciate it if you could help me generate lParam.</p>
0debug
TextInputLayout hint color in error state : <p>As per Googles Material Guidelines:</p> <p><a href="https://material.io/guidelines/components/text-fields.html#text-fields-layout" rel="noreferrer">https://material.io/guidelines/components/text-fields.html#text-fields-layout</a></p> <p>TextInputLayout hint should be the same color as the Error message:</p> <p><a href="https://i.stack.imgur.com/YwawU.png" rel="noreferrer"><img src="https://i.stack.imgur.com/YwawU.png" alt="enter image description here"></a></p> <p>However it is not like that and when I call <code>setError("My error")</code> only the underline and the error message show up in red.</p> <p>How can I change this behavior to account for Google's own guidelines?</p>
0debug
static int oss_run_in (HWVoiceIn *hw) { OSSVoiceIn *oss = (OSSVoiceIn *) hw; int hwshift = hw->info.shift; int i; int live = audio_pcm_hw_get_live_in (hw); int dead = hw->samples - live; size_t read_samples = 0; struct { int add; int len; } bufs[2] = { { hw->wpos, 0 }, { 0, 0 } }; if (!dead) { return 0; } if (hw->wpos + dead > hw->samples) { bufs[0].len = (hw->samples - hw->wpos) << hwshift; bufs[1].len = (dead - (hw->samples - hw->wpos)) << hwshift; } else { bufs[0].len = dead << hwshift; } for (i = 0; i < 2; ++i) { ssize_t nread; if (bufs[i].len) { void *p = advance (oss->pcm_buf, bufs[i].add << hwshift); nread = read (oss->fd, p, bufs[i].len); if (nread > 0) { if (nread & hw->info.align) { dolog ("warning: Misaligned read %zd (requested %d), " "alignment %d\n", nread, bufs[i].add << hwshift, hw->info.align + 1); } read_samples += nread >> hwshift; hw->conv (hw->conv_buf + bufs[i].add, p, nread >> hwshift, &nominal_volume); } if (bufs[i].len - nread) { if (nread == -1) { switch (errno) { case EINTR: case EAGAIN: break; default: oss_logerr ( errno, "Failed to read %d bytes of audio (to %p)\n", bufs[i].len, p ); break; } } break; } } } hw->wpos = (hw->wpos + read_samples) % hw->samples; return read_samples; }
1threat
static void sbr_hf_inverse_filter(float (*alpha0)[2], float (*alpha1)[2], const float X_low[32][40][2], int k0) { int k; for (k = 0; k < k0; k++) { float phi[3][2][2], dk; autocorrelate(X_low[k], phi, 0); autocorrelate(X_low[k], phi, 1); autocorrelate(X_low[k], phi, 2); dk = phi[2][1][0] * phi[1][0][0] - (phi[1][1][0] * phi[1][1][0] + phi[1][1][1] * phi[1][1][1]) / 1.000001f; if (!dk) { alpha1[k][0] = 0; alpha1[k][1] = 0; } else { float temp_real, temp_im; temp_real = phi[0][0][0] * phi[1][1][0] - phi[0][0][1] * phi[1][1][1] - phi[0][1][0] * phi[1][0][0]; temp_im = phi[0][0][0] * phi[1][1][1] + phi[0][0][1] * phi[1][1][0] - phi[0][1][1] * phi[1][0][0]; alpha1[k][0] = temp_real / dk; alpha1[k][1] = temp_im / dk; } if (!phi[1][0][0]) { alpha0[k][0] = 0; alpha0[k][1] = 0; } else { float temp_real, temp_im; temp_real = phi[0][0][0] + alpha1[k][0] * phi[1][1][0] + alpha1[k][1] * phi[1][1][1]; temp_im = phi[0][0][1] + alpha1[k][1] * phi[1][1][0] - alpha1[k][0] * phi[1][1][1]; alpha0[k][0] = -temp_real / phi[1][0][0]; alpha0[k][1] = -temp_im / phi[1][0][0]; } if (alpha1[k][0] * alpha1[k][0] + alpha1[k][1] * alpha1[k][1] >= 16.0f || alpha0[k][0] * alpha0[k][0] + alpha0[k][1] * alpha0[k][1] >= 16.0f) { alpha1[k][0] = 0; alpha1[k][1] = 0; alpha0[k][0] = 0; alpha0[k][1] = 0; } } }
1threat
Minify CSS with Node-sass : <p>I'm using SCSS in my NodeJS project and have my script working to turn all my seperate SCSS files into a single CSS file using the following command</p> <pre><code>node-sass -w public/css/scss/style.scss public/css/style.css </code></pre> <p>My only issue is that I also want the CSS file to be minified. Is this possible with Node-sass? The docs say there is an option for 'compact' but it doesn't seem to work when I try</p> <pre><code>node-sass -w compact public/css/scss/style.scss public/css/style.css </code></pre> <p>Thank you in advance for any help.</p>
0debug
static void gem_write(void *opaque, hwaddr offset, uint64_t val, unsigned size) { CadenceGEMState *s = (CadenceGEMState *)opaque; uint32_t readonly; int i; DB_PRINT("offset: 0x%04x write: 0x%08x ", (unsigned)offset, (unsigned)val); offset >>= 2; val &= ~(s->regs_ro[offset]); readonly = s->regs[offset] & (s->regs_ro[offset] | s->regs_w1c[offset]); s->regs[offset] = (val & ~s->regs_w1c[offset]) | readonly; s->regs[offset] &= ~(s->regs_w1c[offset] & val); switch (offset) { case GEM_NWCTRL: if (val & GEM_NWCTRL_RXENA) { for (i = 0; i < s->num_priority_queues; ++i) { gem_get_rx_desc(s, i); } } if (val & GEM_NWCTRL_TXSTART) { gem_transmit(s); } if (!(val & GEM_NWCTRL_TXENA)) { for (i = 0; i < s->num_priority_queues; i++) { s->tx_desc_addr[i] = s->regs[GEM_TXQBASE]; } } if (gem_can_receive(qemu_get_queue(s->nic))) { qemu_flush_queued_packets(qemu_get_queue(s->nic)); } break; case GEM_TXSTATUS: gem_update_int_status(s); break; case GEM_RXQBASE: s->rx_desc_addr[0] = val; break; case GEM_RECEIVE_Q1_PTR ... GEM_RECEIVE_Q15_PTR: s->rx_desc_addr[offset - GEM_RECEIVE_Q1_PTR + 1] = val; break; case GEM_TXQBASE: s->tx_desc_addr[0] = val; break; case GEM_TRANSMIT_Q1_PTR ... GEM_TRANSMIT_Q15_PTR: s->tx_desc_addr[offset - GEM_TRANSMIT_Q1_PTR + 1] = val; break; case GEM_RXSTATUS: gem_update_int_status(s); break; case GEM_IER: s->regs[GEM_IMR] &= ~val; gem_update_int_status(s); break; case GEM_INT_Q1_ENABLE ... GEM_INT_Q7_ENABLE: s->regs[GEM_INT_Q1_MASK + offset - GEM_INT_Q1_ENABLE] &= ~val; gem_update_int_status(s); break; case GEM_INT_Q8_ENABLE ... GEM_INT_Q15_ENABLE: s->regs[GEM_INT_Q8_MASK + offset - GEM_INT_Q8_ENABLE] &= ~val; gem_update_int_status(s); break; case GEM_IDR: s->regs[GEM_IMR] |= val; gem_update_int_status(s); break; case GEM_INT_Q1_DISABLE ... GEM_INT_Q7_DISABLE: s->regs[GEM_INT_Q1_MASK + offset - GEM_INT_Q1_DISABLE] |= val; gem_update_int_status(s); break; case GEM_INT_Q8_DISABLE ... GEM_INT_Q15_DISABLE: s->regs[GEM_INT_Q8_MASK + offset - GEM_INT_Q8_DISABLE] |= val; gem_update_int_status(s); break; case GEM_SPADDR1LO: case GEM_SPADDR2LO: case GEM_SPADDR3LO: case GEM_SPADDR4LO: s->sar_active[(offset - GEM_SPADDR1LO) / 2] = false; break; case GEM_SPADDR1HI: case GEM_SPADDR2HI: case GEM_SPADDR3HI: case GEM_SPADDR4HI: s->sar_active[(offset - GEM_SPADDR1HI) / 2] = true; break; case GEM_PHYMNTNC: if (val & GEM_PHYMNTNC_OP_W) { uint32_t phy_addr, reg_num; phy_addr = (val & GEM_PHYMNTNC_ADDR) >> GEM_PHYMNTNC_ADDR_SHFT; if (phy_addr == BOARD_PHY_ADDRESS || phy_addr == 0) { reg_num = (val & GEM_PHYMNTNC_REG) >> GEM_PHYMNTNC_REG_SHIFT; gem_phy_write(s, reg_num, val); } } break; } DB_PRINT("newval: 0x%08x\n", s->regs[offset]); }
1threat
where do I select the terminal in Github? : <p>First time working in GitHub, and I am not sure how to access to the "terminal". Any idea? Do I need to install it?</p>
0debug
static int protocol_client_auth_vnc(VncState *vs, uint8_t *data, size_t len) { unsigned char response[VNC_AUTH_CHALLENGE_SIZE]; int i, j, pwlen; unsigned char key[8]; time_t now = time(NULL); if (!vs->vd->password || !vs->vd->password[0]) { VNC_DEBUG("No password configured on server"); goto reject; } if (vs->vd->expires < now) { VNC_DEBUG("Password is expired"); goto reject; } memcpy(response, vs->challenge, VNC_AUTH_CHALLENGE_SIZE); pwlen = strlen(vs->vd->password); for (i=0; i<sizeof(key); i++) key[i] = i<pwlen ? vs->vd->password[i] : 0; deskey(key, EN0); for (j = 0; j < VNC_AUTH_CHALLENGE_SIZE; j += 8) des(response+j, response+j); if (memcmp(response, data, VNC_AUTH_CHALLENGE_SIZE) != 0) { VNC_DEBUG("Client challenge reponse did not match\n"); goto reject; } else { VNC_DEBUG("Accepting VNC challenge response\n"); vnc_write_u32(vs, 0); vnc_flush(vs); start_client_init(vs); } return 0; reject: vnc_write_u32(vs, 1); if (vs->minor >= 8) { static const char err[] = "Authentication failed"; vnc_write_u32(vs, sizeof(err)); vnc_write(vs, err, sizeof(err)); } vnc_flush(vs); vnc_client_error(vs); return 0; }
1threat
Understanding Why I'm Getting a Recursion Error Inside of a Get Method : I'm currently learning about properties and ran into a bit of a problem. When I return my property in the 'get' method, I receive a recursion error. Is this because when ever I return the property it activates the get method, which returns the property, which activates the get method, ect? Here's my code, thanks in advanced. using UnityEngine; struct Enemy { public int Bonus; private int gold; public int Gold { get { return Gold + Bonus; } { gold = value; } } }
0debug
QDict *qtest_qmpv(QTestState *s, const char *fmt, va_list ap) { socket_sendf(s->qmp_fd, fmt, ap); return qtest_qmp_receive(s); }
1threat
How to create set a variable in a Struct in swift that conforms to Decodable and Encodable protocol? : <p>I'm fetching data from an API but this API has a small problem inside location JSON Object, it contains a variable called <code>postcode</code> and this variable can be either a <code>String</code> or a <code>Int</code>.</p> <p>I have to handle this problem locally, If I set <code>var postcode: String</code> I get an error when this value is <code>Int</code> and if I set <code>var postcode: Int</code> I get an error when this value is a <code>String</code></p> <p>so I tried to set <code>var postcode: Any</code> but the following problem occurs...</p> <p><a href="https://i.stack.imgur.com/RN85r.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RN85r.png" alt="enter image description here"></a></p> <p>it when I set this value it doesn't conform to Codable protocol...</p> <p>when I return the way it was before....</p> <p><a href="https://i.stack.imgur.com/RTFmP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RTFmP.png" alt="enter image description here"></a></p> <p>I got no errors BUT it doesn't handle my problem with the API.</p> <p>what am I missing here?</p> <p>thank you in advance for the answers..</p>
0debug
static void test_tco_second_timeout_reset(void) { TestData td; const uint16_t ticks = TCO_SECS_TO_TICKS(16); QDict *ad; td.args = "-watchdog-action reset"; td.noreboot = false; test_init(&td); stop_tco(&td); clear_tco_status(&td); reset_on_second_timeout(true); set_tco_timeout(&td, TCO_SECS_TO_TICKS(16)); load_tco(&td); start_tco(&td); clock_step(ticks * TCO_TICK_NSEC * 2); ad = get_watchdog_action(); g_assert(!strcmp(qdict_get_str(ad, "action"), "reset")); QDECREF(ad); stop_tco(&td); qtest_end(); }
1threat
can we compare two files one is having different fields and other is a c fie using shell script? : I am having two files File1: #include<stdio.h> printf,scanf #include<string.h> strcpy,strcat,strlen #include<time.h> time File2.c: > int main > { > char str1[20] = "BeginnersBook"; > printf("Length of string str1: %d", strlen(str1)); > return 0; > } My Question here is, we have to search for the functions of file1(field2) in file2, if exists then we should write the result to different file named as output, it should contain only the filename and the appropriate header file should be there like File2:headerfile1,headerfile2 It is possible to do it with grep and awk.
0debug
how to create JSpinner alike input field in android : [sample image is here][1] [1]: https://i.stack.imgur.com/sCtlT.png I'm beginner in android, Please help me to create the JSpinner like input field in android.
0debug
How can I export promise result? : <p>Sorry if this question is stupid.</p> <p>This code works correctly. And I just need to export data variable after all promises successfully resolved.</p> <p>I cannot put this code to function and export variable. Because in this case, this function will export an empty array.</p> <pre class="lang-js prettyprint-override"><code>'use strict' import urls from './urls' import getData from './get-data' getData(urls).then((responses) =&gt; { const data = [] const results = responses.map(JSON.parse) for (let i = 0, max = results.length; i &lt; max; i++) { // some magic and pushing } return data }).catch(error =&gt; console.log(error)) </code></pre>
0debug
static void parse_numa_node(MachineState *ms, NumaNodeOptions *node, QemuOpts *opts, Error **errp) { uint16_t nodenr; uint16List *cpus = NULL; MachineClass *mc = MACHINE_GET_CLASS(ms); if (node->has_nodeid) { nodenr = node->nodeid; } else { nodenr = nb_numa_nodes; } if (nodenr >= MAX_NODES) { error_setg(errp, "Max number of NUMA nodes reached: %" PRIu16 "", nodenr); return; } if (numa_info[nodenr].present) { error_setg(errp, "Duplicate NUMA nodeid: %" PRIu16, nodenr); return; } if (!mc->cpu_index_to_instance_props) { error_report("NUMA is not supported by this machine-type"); exit(1); } for (cpus = node->cpus; cpus; cpus = cpus->next) { CpuInstanceProperties props; if (cpus->value >= max_cpus) { error_setg(errp, "CPU index (%" PRIu16 ")" " should be smaller than maxcpus (%d)", cpus->value, max_cpus); return; } props = mc->cpu_index_to_instance_props(ms, cpus->value); props.node_id = nodenr; props.has_node_id = true; machine_set_cpu_numa_node(ms, &props, &error_fatal); } if (node->has_mem && node->has_memdev) { error_setg(errp, "cannot specify both mem= and memdev="); return; } if (have_memdevs == -1) { have_memdevs = node->has_memdev; } if (node->has_memdev != have_memdevs) { error_setg(errp, "memdev option must be specified for either " "all or no nodes"); return; } if (node->has_mem) { uint64_t mem_size = node->mem; const char *mem_str = qemu_opt_get(opts, "mem"); if (g_ascii_isdigit(mem_str[strlen(mem_str) - 1])) { mem_size <<= 20; } numa_info[nodenr].node_mem = mem_size; } if (node->has_memdev) { Object *o; o = object_resolve_path_type(node->memdev, TYPE_MEMORY_BACKEND, NULL); if (!o) { error_setg(errp, "memdev=%s is ambiguous", node->memdev); return; } object_ref(o); numa_info[nodenr].node_mem = object_property_get_uint(o, "size", NULL); numa_info[nodenr].node_memdev = MEMORY_BACKEND(o); } numa_info[nodenr].present = true; max_numa_nodeid = MAX(max_numa_nodeid, nodenr + 1); }
1threat
ssize_t v9fs_list_xattr(FsContext *ctx, const char *path, void *value, size_t vsize) { ssize_t size = 0; char *buffer; void *ovalue = value; XattrOperations *xops; char *orig_value, *orig_value_start; ssize_t xattr_len, parsed_len = 0, attr_len; buffer = rpath(ctx, path); xattr_len = llistxattr(buffer, value, 0); if (xattr_len <= 0) { g_free(buffer); return xattr_len; } orig_value = g_malloc(xattr_len); xattr_len = llistxattr(buffer, orig_value, xattr_len); g_free(buffer); orig_value_start = orig_value; while (xattr_len > parsed_len) { xops = get_xattr_operations(ctx->xops, orig_value); if (!xops) { goto next_entry; } if (!value) { size += xops->listxattr(ctx, path, orig_value, value, vsize); } else { size = xops->listxattr(ctx, path, orig_value, value, vsize); if (size < 0) { goto err_out; } value += size; vsize -= size; } next_entry: attr_len = strlen(orig_value) + 1; parsed_len += attr_len; orig_value += attr_len; } if (value) { size = value - ovalue; } err_out: g_free(orig_value_start); return size; }
1threat
Allow unique $_GET request only? Generate, verify, forbid values : <p>Hello everyone again here, I want to create a PHP script for my software which generates and returns the specific code using one $_GET request with a string and using another verificates this code, then forbid running same string.</p> <p>Something what should work like this: 1st user's software runs "<a href="http://example.com/codes.php?create=" rel="nofollow noreferrer">http://example.com/codes.php?create=</a>" and string like "abc". and script returns code based on "abc", e.g. "4aO45k", "12sdF4" etc. 2nd user's software runs "<a href="http://example.com/codes.php?verify=" rel="nofollow noreferrer">http://example.com/codes.php?verify=</a>" and this code. If this code exists, return true and remove it FOREVER, meaning this code will never be generated again. If this code doesn't exist, return false. If 1st user's software will run "<a href="http://example.com/codes.php?create=abc" rel="nofollow noreferrer">http://example.com/codes.php?create=abc</a>" another code will be generated.</p> <p>In simple words:</p> <pre><code>if $_GET is create, then generate random alphanumeric string, save it and return if $_GET is verify, then check if this string exists, if so, then return true, remove from saved otherwise return false </code></pre> <p>Possible without databases, SQL, mySQL, FireBird...? How do I make it using .ini files as storage?</p> <p>Thanks.</p>
0debug