problem
stringlengths
26
131k
labels
class label
2 classes
How to create and use a lookup table : <p>I have a character vector of misspelled words:</p> <pre><code>wordswrong &lt;- c("veh", "crrts", "ornges") wordscorrect &lt;- c("vehicle", "carrots", "oranges") </code></pre> <p>Here's a dataframe:</p> <pre><code>words &lt;- data.frame(terms = c("crrts oranges", + "car is a veh", + "orngs bannas peas")) </code></pre> <p>How can I go through each word in words$terms and update based on my two vectors?</p>
0debug
av_cold int ff_msmpeg4_decode_init(AVCodecContext *avctx) { MpegEncContext *s = avctx->priv_data; static volatile int done = 0; int i; MVTable *mv; if (ff_h263_decode_init(avctx) < 0) ff_msmpeg4_common_init(s); if (!done) { for(i=0;i<NB_RL_TABLES;i++) { ff_init_rl(&ff_rl_table[i], ff_static_rl_table_store[i]); INIT_VLC_RL(ff_rl_table[0], 642); INIT_VLC_RL(ff_rl_table[1], 1104); INIT_VLC_RL(ff_rl_table[2], 554); INIT_VLC_RL(ff_rl_table[3], 940); INIT_VLC_RL(ff_rl_table[4], 962); INIT_VLC_RL(ff_rl_table[5], 554); mv = &ff_mv_tables[0]; INIT_VLC_STATIC(&mv->vlc, MV_VLC_BITS, mv->n + 1, mv->table_mv_bits, 1, 1, mv->table_mv_code, 2, 2, 3714); mv = &ff_mv_tables[1]; INIT_VLC_STATIC(&mv->vlc, MV_VLC_BITS, mv->n + 1, mv->table_mv_bits, 1, 1, mv->table_mv_code, 2, 2, 2694); INIT_VLC_STATIC(&ff_msmp4_dc_luma_vlc[0], DC_VLC_BITS, 120, &ff_table0_dc_lum[0][1], 8, 4, &ff_table0_dc_lum[0][0], 8, 4, 1158); INIT_VLC_STATIC(&ff_msmp4_dc_chroma_vlc[0], DC_VLC_BITS, 120, &ff_table0_dc_chroma[0][1], 8, 4, &ff_table0_dc_chroma[0][0], 8, 4, 1118); INIT_VLC_STATIC(&ff_msmp4_dc_luma_vlc[1], DC_VLC_BITS, 120, &ff_table1_dc_lum[0][1], 8, 4, &ff_table1_dc_lum[0][0], 8, 4, 1476); INIT_VLC_STATIC(&ff_msmp4_dc_chroma_vlc[1], DC_VLC_BITS, 120, &ff_table1_dc_chroma[0][1], 8, 4, &ff_table1_dc_chroma[0][0], 8, 4, 1216); INIT_VLC_STATIC(&v2_dc_lum_vlc, DC_VLC_BITS, 512, &ff_v2_dc_lum_table[0][1], 8, 4, &ff_v2_dc_lum_table[0][0], 8, 4, 1472); INIT_VLC_STATIC(&v2_dc_chroma_vlc, DC_VLC_BITS, 512, &ff_v2_dc_chroma_table[0][1], 8, 4, &ff_v2_dc_chroma_table[0][0], 8, 4, 1506); INIT_VLC_STATIC(&v2_intra_cbpc_vlc, V2_INTRA_CBPC_VLC_BITS, 4, &ff_v2_intra_cbpc[0][1], 2, 1, &ff_v2_intra_cbpc[0][0], 2, 1, 8); INIT_VLC_STATIC(&v2_mb_type_vlc, V2_MB_TYPE_VLC_BITS, 8, &ff_v2_mb_type[0][1], 2, 1, &ff_v2_mb_type[0][0], 2, 1, 128); INIT_VLC_STATIC(&v2_mv_vlc, V2_MV_VLC_BITS, 33, &ff_mvtab[0][1], 2, 1, &ff_mvtab[0][0], 2, 1, 538); INIT_VLC_STATIC(&ff_mb_non_intra_vlc[0], MB_NON_INTRA_VLC_BITS, 128, &ff_wmv2_inter_table[0][0][1], 8, 4, &ff_wmv2_inter_table[0][0][0], 8, 4, 1636); INIT_VLC_STATIC(&ff_mb_non_intra_vlc[1], MB_NON_INTRA_VLC_BITS, 128, &ff_wmv2_inter_table[1][0][1], 8, 4, &ff_wmv2_inter_table[1][0][0], 8, 4, 2648); INIT_VLC_STATIC(&ff_mb_non_intra_vlc[2], MB_NON_INTRA_VLC_BITS, 128, &ff_wmv2_inter_table[2][0][1], 8, 4, &ff_wmv2_inter_table[2][0][0], 8, 4, 1532); INIT_VLC_STATIC(&ff_mb_non_intra_vlc[3], MB_NON_INTRA_VLC_BITS, 128, &ff_wmv2_inter_table[3][0][1], 8, 4, &ff_wmv2_inter_table[3][0][0], 8, 4, 2488); INIT_VLC_STATIC(&ff_msmp4_mb_i_vlc, MB_INTRA_VLC_BITS, 64, &ff_msmp4_mb_i_table[0][1], 4, 2, &ff_msmp4_mb_i_table[0][0], 4, 2, 536); INIT_VLC_STATIC(&ff_inter_intra_vlc, INTER_INTRA_VLC_BITS, 4, &ff_table_inter_intra[0][1], 2, 1, &ff_table_inter_intra[0][0], 2, 1, 8); done = 1; switch(s->msmpeg4_version){ case 1: case 2: s->decode_mb= msmpeg4v12_decode_mb; break; case 3: case 4: s->decode_mb= msmpeg4v34_decode_mb; break; case 5: if (CONFIG_WMV2_DECODER) s->decode_mb= ff_wmv2_decode_mb; case 6: break; s->slice_height= s->mb_height; return 0;
1threat
Can we have class name with alphanumeric character? : <p>Can we name class using alphanumeric values ?like class Tier1, Tier2 and so on.Is this come under good practice. What is the recommendation around naming class. I know this is very generic question and simple one however there were instance during code review I often came across class names which seems to be usual.</p>
0debug
Angular2 refreshing view on array push : <p>I can't seem to get angular2 view to be updated on an array.push function, called upon from a setInterval async operation.</p> <p>the code is from this <a href="http://plnkr.co/edit/GC512b?p=preview" rel="noreferrer">angular plunkr example of setInterval</a>:</p> <p>What i'm trying to do is as follows:</p> <p><div class="snippet" data-lang="js" data-hide="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>import {View, Component, bootstrap, Directive, ChangeDetectionStrategy, ChangeDetectorRef} from 'angular2/angular2' @Component({selector: 'cmp', changeDetection: ChangeDetectionStrategy.OnPush}) @View({template: `Number of ticks: {{numberOfTicks}}`}) class Cmp { numberOfTicks = []; constructor(private ref: ChangeDetectorRef) { setInterval(() =&gt; { this.numberOfTicks.push(3); this.ref.markForCheck(); }, 1000); } } @Component({ selector: 'app', changeDetection: ChangeDetectionStrategy.OnPush }) @View({ template: ` &lt;cmp&gt;&lt;cmp&gt; `, directives: [Cmp] }) class App { } bootstrap(App);</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;angular2 playground&lt;/title&gt; &lt;script src="https://code.angularjs.org/tools/traceur-runtime.js"&gt;&lt;/script&gt; &lt;script src="https://code.angularjs.org/tools/system.js"&gt;&lt;/script&gt; &lt;script src="https://code.angularjs.org/tools/typescript.js"&gt;&lt;/script&gt; &lt;script data-require="jasmine" data-semver="2.2.1" src="http://cdnjs.cloudflare.com/ajax/libs/jasmine/2.2.1/jasmine.js"&gt;&lt;/script&gt; &lt;script data-require="jasmine" data-semver="2.2.1" src="http://cdnjs.cloudflare.com/ajax/libs/jasmine/2.2.1/jasmine-html.js"&gt;&lt;/script&gt; &lt;script data-require="jasmine@*" data-semver="2.2.1" src="http://cdnjs.cloudflare.com/ajax/libs/jasmine/2.2.1/boot.js"&gt;&lt;/script&gt; &lt;script src="config.js"&gt;&lt;/script&gt; &lt;script src="https://code.angularjs.org/2.0.0-alpha.37/angular2.min.js"&gt;&lt;/script&gt; &lt;script&gt; System.import('app') .catch(console.error.bind(console)); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;app&gt;&lt;/app&gt; &lt;/body&gt; &lt;/html&gt;</code></pre> </div> </div> </p> <p>The above code will work properly if "numberOfTicks" is just a number, (as the plunker original example shows) but once I change it to an array and push data, it won't update.</p> <p>I can't seem to understand why is that.</p> <p>The following behaviour is similar to an issue I have when trying to update a graph in angular2 with new data points when using setInterval / setTimeout.</p> <p>Thanks for the help.</p>
0debug
Cannot convert LocalDate to Timestamp : <p>I'm trying to convert a LocalDate to Timestamp but it keeps saying: <code>valueOf(java.lang.String) in Timestamp cannot be applied to (java.time.LocalDateTime)</code></p> <p>What I'm doing:</p> <pre><code>LocalDate date = LocalDate.of(year, month+1, day); Timestamp ts = Timestamp.valueOf(date.atTime(LocalTime.MIDNIGHT)); </code></pre> <p>Year, month and day are from a DatePicker.</p>
0debug
Android development kit sdk setup : I am learning Android app development with udacity. I have downloaded Android development kit but when I installed it ask for sdk setup. I have check on YouTube but there I can't find related video. Plz any one could give a link for video or just point out me ways for installing it.
0debug
How i can deny mouse selection in tag <input type="text">? : There is html-code: <input type="text"> I need to deny selecting text in <input> Thank you
0debug
What is the regex for checking format of a string : What is the regex for finding if user input is properly formatted? Format should follow: `AAAA-123` or `AAAA123` Where the first 4 characters are letters in the range A-M and the following 3 characters are numbers with a max of 299
0debug
C++ CLI Wrapper for native functions : I'm trying to create a C++ CLI .Net wrapper for some native DLLs. There is seven of these DLLs and more in the future so i need to load the dynamically. They all have the same set of functions. LoadLibrary and GetProcAddress worked great in a native application to load these functions. Whenever i load a DLL, and call Initialize i get AccessViolationException. Not really sure why. It seems to Load the DLL fine and also the function "TSRInit" If I pass in a path to the DLL i know is incorrect it tells me loading it failed. But doesnt say failed if I pass the correct path. Likewise, Loading "TRInit" seems to work. If i pass in a function name that doesnt exist it also tells me. Im testing with a C# Console app with platform x86 selected. typedef long (WINAPI *TSRINIT)(long lType, HWND hParent, RECT *pRect); namespace Imagery { public ref class Recongizer { public: Recongizer(String^ DllPath) { LoadRecongizer(DllPath); } ~Recongizer() { UnloadLibrary(); } bool LoadRecongizer(String^ DllPath) { HInstance = ::LoadLibrary(msclr::interop::marshal_as<std::wstring>(DllPath).c_str()); if (HInstance == nullptr) return false; if (!LoadFunctions()) return false; return true; } long Initalize(long lType) { if (HInstance == nullptr) return 0; return TSInit(0, nullptr, nullptr); } private: void UnloadLibrary() { if (HInstance != nullptr) ::FreeLibrary(HInstance); } bool LoadFunctions() { TSInit = (TSRINIT)::GetProcAddress(HInstance, "TSRInit"); if (TSInit == nullptr) { ErrorMessage = "TSRInit could not be loaded."; return false; } return true; } property String^ ErrorMessage; private: HINSTANCE HInstance{ nullptr }; TSRINIT TSInit{ nullptr }; }; }
0debug
File Regex with extension c# : <p>I want to check the name of the file. it supposed to accept only letters with an extension of .xlsm </p> <p>I tried this: </p> <blockquote> <p>^[a-zA-Z]+$.xlsm</p> </blockquote> <p>can anybody please explain a little bit about this regex if it is correct. what the ^, +, $ means? and should I add something? </p> <p>thank you</p>
0debug
Notepad-like GUI text editor for Linux/Ubuntu (SSH into an Ubuntu Server 14.04 LTS AWS instance) : <p>I am not so familiar with Linux/Ubuntu bash command line. I am currently ssh'ing (using ConEmu) into an AWS instance (Ubuntu Server 14.04 LTS) in order to setup a Jupyter notebook server. However, in a part of the documentation in requires editing a file using the vim editor. Vim seems a but confusing right now to learn and I just need to edit a couple lines.</p> <p>Is there something similar in linux to the windows command line:</p> <pre><code>notepad file_name.txt </code></pre> <p>that opens a text file in a GUI for editing/saving. Is there a similar command line argument in Linux? Or something I can install which will give me this ability?</p> <p>Thanks</p>
0debug
which one of these returns a registry value? : <https://docs.microsoft.com/en-us/windows/win32/sysinfo/retrieving-data-from-the-registry> is confusing me. All I want is to retrieve the value of particular registry key. Which one of the functions do I use? Many thank, -T
0debug
static int codec_reinit(AVCodecContext *avctx, int width, int height, int quality) { NuvContext *c = avctx->priv_data; width = (width + 1) & ~1; height = (height + 1) & ~1; if (quality >= 0) get_quant_quality(c, quality); if (width != c->width || height != c->height) { if (av_image_check_size(height, width, 0, avctx) < 0) return 0; avctx->width = c->width = width; avctx->height = c->height = height; c->decomp_size = c->height * c->width * 3 / 2; c->decomp_buf = av_realloc(c->decomp_buf, c->decomp_size + AV_LZO_OUTPUT_PADDING); if (!c->decomp_buf) { av_log(avctx, AV_LOG_ERROR, "Can't allocate decompression buffer.\n"); return 0; } rtjpeg_decode_init(&c->rtj, &c->dsp, c->width, c->height, c->lq, c->cq); } else if (quality != c->quality) rtjpeg_decode_init(&c->rtj, &c->dsp, c->width, c->height, c->lq, c->cq); return 1; }
1threat
How to Multiply / Sum with Javascript : <p><a href="https://jsbin.com/wujusajowa/1/edit?html,js,output" rel="nofollow">https://jsbin.com/wujusajowa/1/edit?html,js,output</a></p> <p>I can sum the numbers of options. Like (5+5+5=15)</p> <p>But I don't know a way to multiply the input with the sum of selects.</p> <p>For example, What should I do to do <strong>6 x</strong> (5+5+5) and get 90 ?</p>
0debug
flutter build apk create old version app : <p>I am a new flutter programmer and i am trying to build my release app in flutter and when i run </p> <p><code>flutter run</code></p> <p>everything work fine in debug and test mode. but when i was trying to build a release app with </p> <p><code>flutter build apk</code> </p> <p>it create a old first release app of mine . that i created before and i try to reset computer reset android and everything but not work what can i do to reset it and clear the cache? im trying almost delete and reset everything but they dont work. what command that i have to run to fix it and create new version realease apk</p>
0debug
void bdrv_set_backing_hd(BlockDriverState *bs, BlockDriverState *backing_hd) { if (bs->backing_hd) { assert(bs->backing_blocker); bdrv_op_unblock_all(bs->backing_hd, bs->backing_blocker); } else if (backing_hd) { error_setg(&bs->backing_blocker, "device is used as backing hd of '%s'", bdrv_get_device_name(bs)); } bs->backing_hd = backing_hd; if (!backing_hd) { error_free(bs->backing_blocker); bs->backing_blocker = NULL; goto out; } bs->open_flags &= ~BDRV_O_NO_BACKING; pstrcpy(bs->backing_file, sizeof(bs->backing_file), backing_hd->filename); pstrcpy(bs->backing_format, sizeof(bs->backing_format), backing_hd->drv ? backing_hd->drv->format_name : ""); bdrv_op_block_all(bs->backing_hd, bs->backing_blocker); bdrv_op_unblock(bs->backing_hd, BLOCK_OP_TYPE_COMMIT, bs->backing_blocker); out: bdrv_refresh_limits(bs, NULL); }
1threat
Use rle to group by runs when using dplyr : <p>In R, I want to summarize my data after grouping it based on the runs of a variable <code>x</code> (aka each group of the data corresponds to a subset of the data where consecutive <code>x</code> values are the same). For instance, consider the following data frame, where I want to compute the average <code>y</code> value within each run of <code>x</code>:</p> <pre><code>(dat &lt;- data.frame(x=c(1, 1, 1, 2, 2, 1, 2), y=1:7)) # x y # 1 1 1 # 2 1 2 # 3 1 3 # 4 2 4 # 5 2 5 # 6 1 6 # 7 2 7 </code></pre> <p>In this example, the <code>x</code> variable has runs of length 3, then 2, then 1, and finally 1, taking values 1, 2, 1, and 2 in those four runs. The corresponding means of <code>y</code> in those groups are 2, 4.5, 6, and 7.</p> <p>It is easy to carry out this grouped operation in base R using <code>tapply</code>, passing <code>dat$y</code> as the data, using <code>rle</code> to compute the run number from <code>dat$x</code>, and passing the desired summary function:</p> <pre><code>tapply(dat$y, with(rle(dat$x), rep(seq_along(lengths), lengths)), mean) # 1 2 3 4 # 2.0 4.5 6.0 7.0 </code></pre> <p>I figured I would be able to pretty directly carry over this logic to dplyr, but my attempts so far have all ended in errors:</p> <pre><code>library(dplyr) # First attempt dat %&gt;% group_by(with(rle(x), rep(seq_along(lengths), lengths))) %&gt;% summarize(mean(y)) # Error: cannot coerce type 'closure' to vector of type 'integer' # Attempt 2 -- maybe "with" is the problem? dat %&gt;% group_by(rep(seq_along(rle(x)$lengths), rle(x)$lengths)) %&gt;% summarize(mean(y)) # Error: invalid subscript type 'closure' </code></pre> <p>For completeness, I could reimplement the <code>rle</code> run id myself using <code>cumsum</code>, <code>head</code>, and <code>tail</code> to get around this, but it makes the grouping code tougher to read and involves a bit of reinventing the wheel:</p> <pre><code>dat %&gt;% group_by(run=cumsum(c(1, head(x, -1) != tail(x, -1)))) %&gt;% summarize(mean(y)) # run mean(y) # (dbl) (dbl) # 1 1 2.0 # 2 2 4.5 # 3 3 6.0 # 4 4 7.0 </code></pre> <p>What is causing my <code>rle</code>-based grouping code to fail in <code>dplyr</code>, and is there any solution that enables me to keep using <code>rle</code> when grouping by run id?</p>
0debug
Brain teaser - php array manipulation : I have following array: <pre> array(174) { [0]=> string(5) "3.0.3" [1]=> string(5) "3.0.2" [2]=> string(5) "3.0.1" [3]=> string(5) "3.0.0" [9]=> string(5) "2.9.5" [10]=> string(5) "2.9.4" [11]=> string(5) "2.9.3" [12]=> string(5) "2.9.2" [13]=> string(5) "2.9.1" [14]=> string(5) "2.9.0" [18]=> string(6) "2.8.11" [19]=> string(6) "2.8.10" [20]=> string(5) "2.8.9" } </pre> I need to find the highest 3rd number for unique pair of first two numbers x.x. With this example the expected result must be 3.0.3, 2.9.5, 2.8.11.
0debug
Unsupported Operation Exception Java.Sql.Date : <p>hello i need to display a date column in a tableview; in the database I declare the field <code>fecha_nacimiento</code> as <code>date</code> , i used a <code>datepicker</code> to insert that data into the database, so far its Ok with that operation so the next step was formatting the tableview cell to display the date data correctly, with the help of this site i did that, but when i need to retrieve the date data from the database i am getting an error, something like this:</p> <pre><code>Caused by: java.lang.UnsupportedOperationException at java.sql.Date.toInstant(Unknown Source) </code></pre> <p>this is some of my <code>controller</code> code</p> <pre><code>public void initialize(URL arg0, ResourceBundle arg1) { clienteid.setCellValueFactory(new PropertyValueFactory &lt;Persona, Integer&gt;("id_cliente")); nombrescol.setCellValueFactory(new PropertyValueFactory &lt;Persona, String&gt;("nombres")); apellidoscol.setCellValueFactory(new PropertyValueFactory &lt;Persona, String&gt;("apellidos")); //fechacli.setCellValueFactory(new PropertyValueFactory &lt;Persona, LocalDate&gt;("fechacliente"));// DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy"); fechacli.setCellFactory(column -&gt; { return new TableCell&lt;Persona, LocalDate&gt;() { @Override protected void updateItem(LocalDate item, boolean empty) { super.updateItem(item, empty); if (item == null || empty) { setText(null); } else { setText(formatter.format(item)); } } }; }); seleccionaregistros(); seleccionanombre(); seleccionapellido(); } public void seleccionaregistros() { ObservableList &lt;Persona&gt; data =FXCollections.observableArrayList(); Connection conn=null;{ try { conn = DriverManager.getConnection("jdbc:sqlserver://localhost:1433;databaseName=prueba", "sa", "milkas87"); Statement mostrar=conn.createStatement(); ResultSet rs; rs= mostrar.executeQuery("select * from cliente"); while ( rs.next() ) { data.add(new Persona( rs.getString("nombre"), rs.getString("apellido"), rs.getInt("id"), rs.getDate(4).toInstant().atZone(ZoneId.systemDefault()).toLocalDate()) ); tablacliente.setItems(data); } } catch (SQLException e) { e.printStackTrace(); } } } </code></pre> <p>this is my <code>persona class</code> code</p> <pre><code>package application; import java.time.LocalDate; import javafx.beans.property.IntegerProperty; import javafx.beans.property.ObjectProperty; import javafx.beans.property.SimpleIntegerProperty; import javafx.beans.property.SimpleObjectProperty; import javafx.beans.property.SimpleStringProperty; import javafx.beans.property.StringProperty; public class Persona { private StringProperty nombres; private StringProperty apellidos; private IntegerProperty id_cliente; private ObjectProperty &lt;LocalDate&gt;fechacliente; public Persona (String nombres, String apellidos, Integer id_cliente, LocalDate fechacliente) { this.nombres= new SimpleStringProperty (nombres); this.apellidos= new SimpleStringProperty ( apellidos); this.id_cliente=new SimpleIntegerProperty (id_cliente); this.fechacliente= new SimpleObjectProperty&lt;&gt;(fechacliente); } public LocalDate getFechaCliente() { return fechacliente.get(); } public void setFechaCliente(LocalDate fechacliente) { this.fechacliente = new SimpleObjectProperty&lt;&gt;(fechacliente); } public ObjectProperty&lt;LocalDate&gt; fechaClienteProperty() { return fechacliente; } public String getNombres() { return nombres.get(); } public void setNombres(String nombres) { this.nombres=new SimpleStringProperty (nombres); } public String getApellidos() { return apellidos.get(); } public void setApellidos(String apellidos) { this.apellidos=new SimpleStringProperty ( apellidos); } public Integer getId_cliente() { return id_cliente.get(); } public void setid_cliente(Integer id_cliente) { this.id_cliente=new SimpleIntegerProperty (id_cliente); } } </code></pre> <p>id have been reading, and i found that can't truncate or pass the data beetween Localdate and Date, so any help could be truly helpful. regards.</p> <p>all the errors here:</p> <pre><code>javafx.fxml.LoadException: /C:/Users/ROA%20PC/eclipse-workspace/Conexion/bin/application/Vista.fxml at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2601) at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2579) at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2441) at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3214) at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3175) at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3148) at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3124) at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3104) at javafx.fxml.FXMLLoader.load(FXMLLoader.java:3097) at application.Main.start(Main.java:23) at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:863) at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326) at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295) at java.security.AccessController.doPrivileged(Native Method) at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294) at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95) at com.sun.glass.ui.win.WinApplication._runLoop(Native Method) at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191) at java.lang.Thread.run(Unknown Source) Caused by: java.lang.UnsupportedOperationException at java.sql.Date.toInstant(Unknown Source) at application.ConexionController.seleccionaregistros(ConexionController.java:190) at application.ConexionController.initialize(ConexionController.java:92) at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2548) ... 17 more Exception in Application start method java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389) at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at sun.launcher.LauncherHelper$FXHelper.main(Unknown Source) Caused by: java.lang.RuntimeException: Exception in Application start method at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917) at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$155(LauncherImpl.java:182) at java.lang.Thread.run(Unknown Source) Caused by: java.lang.NullPointerException: Root cannot be null at javafx.scene.Scene.&lt;init&gt;(Scene.java:336) at javafx.scene.Scene.&lt;init&gt;(Scene.java:235) at application.Main.start(Main.java:27) at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:863) at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326) at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295) at java.security.AccessController.doPrivileged(Native Method) at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294) at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95) at com.sun.glass.ui.win.WinApplication._runLoop(Native Method) at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191) ... 1 more Exception running application application.Main </code></pre>
0debug
static void ioq_submit(LinuxAioState *s) { int ret, len; struct qemu_laiocb *aiocb; struct iocb *iocbs[MAX_QUEUED_IO]; QSIMPLEQ_HEAD(, qemu_laiocb) completed; do { len = 0; QSIMPLEQ_FOREACH(aiocb, &s->io_q.pending, next) { iocbs[len++] = &aiocb->iocb; if (len == MAX_QUEUED_IO) { break; } } ret = io_submit(s->ctx, len, iocbs); if (ret == -EAGAIN) { break; } if (ret < 0) { abort(); } s->io_q.n -= ret; aiocb = container_of(iocbs[ret - 1], struct qemu_laiocb, iocb); QSIMPLEQ_SPLIT_AFTER(&s->io_q.pending, aiocb, next, &completed); } while (ret == len && !QSIMPLEQ_EMPTY(&s->io_q.pending)); s->io_q.blocked = (s->io_q.n > 0); }
1threat
Selenium Chrome window running in second monitor screen stealing focus : <p>I use WebDriver with Chrome Driver 2.35 with Selenium. </p> <p>I have a dual monitor setup in which I run my test cases. I do run my cases headlessly most of the times but sometimes, when I want to debug, I run it with the browser. </p> <p>The window opens, I drag it to my second monitor and continue working with other stuff in my primary monitor. But whenever there is an action in the secondary Chrome Selenium screen, the focus shifts to that window and I lose control. </p> <p>This is really annoying, has anyone else faced this issue? Any solutions?</p>
0debug
Enable/disable a button in pure javascript : <p>I want to enable/disable a button without jquery. Here's my code:</p> <pre><code>btn.setAttribute("disabled", true); </code></pre> <p>Works. But this doesn't -- a button remains disabled:</p> <pre><code>btn.setAttribute("disabled", false); </code></pre>
0debug
After instalation - "Sorry, the page you are looking for could not be found" : I installed Laravel on my server running on `Debian 9.6` with Apache. I run command `composer create-project laravel/laravel api 5.5.*` in folder one of my site etc. `name.com`. I want to access it through URL: `https://name.com/api/public` - but I'm getting error on fresh new installation said '**Sorry, the page you are looking for could not be found.**'. Also I tried to run it with `php artisan serve --host=0.0.0.0` but it show same page. In logs I found `[Tue Dec 18 16:15:30.818500 2018] [autoindex:error] [pid 2334] [client 81.2.249.13:36972] AH01276: Cannot serve directory /var/www/name/www/: No matching DirectoryIndex (index.html,index.cgi,index.pl,index.php,index.xhtml,index.htm) found, and server-generated directory index forbidden by Options directive` I've tried a lot of things, that I found here or on google, but nothing helped me. Thanks for any advice.
0debug
How to play videos of any other website into my website using PHP? : <p>I want to play a videos of other's website, in to my website. If I use, iframe tag, it will show a full website of third party. i don't want full website, i want to play only the video part. for example, youtube provide the embed video code. it's fine to use youtube videos. but other websites didn't provide, api like youtube, how i use that website's video in to my website. if i use curl library, i can fetch string data of third party website. but i can't fetch video files. how to do that?</p>
0debug
static void vfio_probe_nvidia_bar0_88000_quirk(VFIODevice *vdev, int nr) { PCIDevice *pdev = &vdev->pdev; VFIOQuirk *quirk; if (!vdev->has_vga || nr != 0 || pci_get_word(pdev->config + PCI_VENDOR_ID) != PCI_VENDOR_ID_NVIDIA) { return; } quirk = g_malloc0(sizeof(*quirk)); quirk->vdev = vdev; quirk->data.flags = quirk->data.read_flags = quirk->data.write_flags = 1; quirk->data.address_match = 0x88000; quirk->data.address_mask = PCIE_CONFIG_SPACE_SIZE - 1; quirk->data.bar = nr; memory_region_init_io(&quirk->mem, OBJECT(vdev), &vfio_generic_quirk, quirk, "vfio-nvidia-bar0-88000-quirk", TARGET_PAGE_ALIGN(quirk->data.address_mask + 1)); memory_region_add_subregion_overlap(&vdev->bars[nr].mem, quirk->data.address_match & TARGET_PAGE_MASK, &quirk->mem, 1); QLIST_INSERT_HEAD(&vdev->bars[nr].quirks, quirk, next); DPRINTF("Enabled NVIDIA BAR0 0x88000 quirk for device %04x:%02x:%02x.%x\n", vdev->host.domain, vdev->host.bus, vdev->host.slot, vdev->host.function); }
1threat
document.write('<script src="evil.js"></script>');
1threat
static void vnc_display_close(VncDisplay *vs) { if (!vs) return; g_free(vs->display); vs->display = NULL; if (vs->lsock != -1) { qemu_set_fd_handler2(vs->lsock, NULL, NULL, NULL, NULL); close(vs->lsock); vs->lsock = -1; } #ifdef CONFIG_VNC_WS g_free(vs->ws_display); vs->ws_display = NULL; if (vs->lwebsock != -1) { qemu_set_fd_handler2(vs->lwebsock, NULL, NULL, NULL, NULL); close(vs->lwebsock); vs->lwebsock = -1; } #endif vs->auth = VNC_AUTH_INVALID; #ifdef CONFIG_VNC_TLS vs->subauth = VNC_AUTH_INVALID; vs->tls.x509verify = 0; #endif }
1threat
What is the Elasticsearch-py equivalent to alias actions? : <p>I am trying to implement <a href="https://www.elastic.co/guide/en/elasticsearch/guide/current/multiple-indices.html#multiple-indices" rel="noreferrer">multiples indices</a> approach using <a href="https://elasticsearch-dsl.readthedocs.io/en/latest/" rel="noreferrer">elasticsearch-dsl</a>. There are basically two steps:</p> <p><strong>1. Create aliases:</strong></p> <pre><code>PUT /tweets_1/_alias/tweets_search PUT /tweets_1/_alias/tweets_index </code></pre> <p><strong>2. Change alias when necessary:</strong></p> <pre><code>POST /_aliases { "actions": [ { "add": { "index": "tweets_2", "alias": "tweets_search" }}, { "remove": { "index": "tweets_1", "alias": "tweets_index" }}, { "add": { "index": "tweets_2", "alias": "tweets_index" }} ] } </code></pre> <p>I could only implement the step 1 using <a href="http://elasticsearch-py.readthedocs.io/en/master/index.html" rel="noreferrer">elasticsearch-py</a> (not the dsl):</p> <pre><code>from elasticsearch.client import IndicesClient IndicesClient(client).("tweets_1", "tweets_search") IndicesClient(client).("tweets_1", "tweets_index") </code></pre> <p>I have no clue how to do that for step 2. So, what would be the equivalent in elasticsearch-dsl (or at least in elasticsearch-py)?</p>
0debug
static int fetch_active_ports_list(QEMUFile *f, int version_id, VirtIOSerial *s, uint32_t nr_active_ports) { uint32_t i; s->post_load = g_malloc0(sizeof(*s->post_load)); s->post_load->nr_active_ports = nr_active_ports; s->post_load->connected = g_malloc0(sizeof(*s->post_load->connected) * nr_active_ports); s->post_load->timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, virtio_serial_post_load_timer_cb, s); for (i = 0; i < nr_active_ports; i++) { VirtIOSerialPort *port; uint32_t id; id = qemu_get_be32(f); port = find_port_by_id(s, id); if (!port) { return -EINVAL; } port->guest_connected = qemu_get_byte(f); s->post_load->connected[i].port = port; s->post_load->connected[i].host_connected = qemu_get_byte(f); if (version_id > 2) { uint32_t elem_popped; qemu_get_be32s(f, &elem_popped); if (elem_popped) { qemu_get_be32s(f, &port->iov_idx); qemu_get_be64s(f, &port->iov_offset); qemu_get_buffer(f, (unsigned char *)&port->elem, sizeof(port->elem)); virtqueue_map(&port->elem); virtio_serial_throttle_port(port, false); } } } timer_mod(s->post_load->timer, 1); return 0; }
1threat
void spapr_setup_hpt_and_vrma(sPAPRMachineState *spapr) { int hpt_shift; if ((spapr->resize_hpt == SPAPR_RESIZE_HPT_DISABLED) || (spapr->cas_reboot && !spapr_ovec_test(spapr->ov5_cas, OV5_HPT_RESIZE))) { hpt_shift = spapr_hpt_shift_for_ramsize(MACHINE(spapr)->maxram_size); } else { hpt_shift = spapr_hpt_shift_for_ramsize(MACHINE(spapr)->ram_size); } spapr_reallocate_hpt(spapr, hpt_shift, &error_fatal); if (spapr->vrma_adjust) { spapr->rma_size = kvmppc_rma_size(spapr_node0_size(MACHINE(spapr)), spapr->htab_shift); } spapr->patb_entry = 0; }
1threat
Use of Ifelse and Or in R : <p>I have a dataset named SPT which has one column which consist 4 unique values-A,B,C,D, Now I have to create one more column which consist of 1 if first column had A, B otherwise 0.How to do it using ifelse command</p>
0debug
can anyone suggest a best way to give permanent usb permission to an android application note that i am using android 5.1 rooted device? : I am developing an application which requires permanent permission for using usb host, on every restart the application will require fresh permission for using USB is there any way one can bypass the dialogbox and give the application permissions it needs.
0debug
percentEven, won't compile : <p>So this is the percentEven method from the Java textbook. I cannot get it to compile and was wondering if you guys could see my mistake.</p> <p>"Write a method called "percentEven" that accepts an array of integers as a parameter and returns the percentage of even numbers in the array as a real number."</p> <p>that is the instructions. this is what I have so far.</p> <pre><code>import java.util.*; public class percentEven { public class void main ( String [] args ) { int [] integers = {34, 56, 4, 17, 9, 83, -300, 5}; int evenResult = percentEven (integers); System.out.println ( " The percent of even numbers is" + evenResult + "." ); } public class int percentEven ( int [] integers ) { int count = 0; int even = 0; for (i=0,i&lt;integers.length,i++){ if ( integers[i] % 2 == 0 ){ even++; } count++; } count= (even/count)*100; return count; } } </code></pre>
0debug
Google Cloud Text-to-speech word timestamps : <p>I'm generating speech through Google Cloud's text-to-speech API and I'd like to highlight words as they are spoken.</p> <p>Is there a way of getting timestamps for spoken words or sentences?</p>
0debug
static HEVCFrame *find_ref_idx(HEVCContext *s, int poc) { int i; int LtMask = (1 << s->sps->log2_max_poc_lsb) - 1; for (i = 0; i < FF_ARRAY_ELEMS(s->DPB); i++) { HEVCFrame *ref = &s->DPB[i]; if (ref->frame->buf[0] && (ref->sequence == s->seq_decode)) { if ((ref->poc & LtMask) == poc) return ref; } } for (i = 0; i < FF_ARRAY_ELEMS(s->DPB); i++) { HEVCFrame *ref = &s->DPB[i]; if (ref->frame->buf[0] && ref->sequence == s->seq_decode) { if (ref->poc == poc || (ref->poc & LtMask) == poc) return ref; } } av_log(s->avctx, AV_LOG_ERROR, "Could not find ref with POC %d\n", poc); return NULL; }
1threat
static void IRQ_check(OpenPICState *opp, IRQ_queue_t *q) { int next, i; int priority; next = -1; priority = -1; if (!q->pending) { goto out; } for (i = 0; i < opp->max_irq; i++) { if (IRQ_testbit(q, i)) { DPRINTF("IRQ_check: irq %d set ipvp_pr=%d pr=%d\n", i, IPVP_PRIORITY(opp->src[i].ipvp), priority); if (IPVP_PRIORITY(opp->src[i].ipvp) > priority) { next = i; priority = IPVP_PRIORITY(opp->src[i].ipvp); } } } out: q->next = next; q->priority = priority; }
1threat
static void output_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost) { int ret = 0; if (ost->nb_bitstream_filters) { int idx; ret = av_bsf_send_packet(ost->bsf_ctx[0], pkt); if (ret < 0) goto finish; idx = 1; while (idx) { ret = av_bsf_receive_packet(ost->bsf_ctx[idx - 1], pkt); if (!(ost->bsf_extradata_updated[idx - 1] & 1)) { ret = avcodec_parameters_copy(ost->st->codecpar, ost->bsf_ctx[idx - 1]->par_out); if (ret < 0) goto finish; ost->bsf_extradata_updated[idx - 1] |= 1; } if (ret == AVERROR(EAGAIN)) { ret = 0; idx--; continue; } else if (ret < 0) goto finish; if (idx < ost->nb_bitstream_filters) { if (!(ost->bsf_extradata_updated[idx] & 2)) { ret = avcodec_parameters_copy(ost->bsf_ctx[idx]->par_out, ost->bsf_ctx[idx - 1]->par_out); if (ret < 0) goto finish; ost->bsf_extradata_updated[idx] |= 2; } ret = av_bsf_send_packet(ost->bsf_ctx[idx], pkt); if (ret < 0) goto finish; idx++; } else write_packet(of, pkt, ost); } } else write_packet(of, pkt, ost); finish: if (ret < 0 && ret != AVERROR_EOF) { av_log(NULL, AV_LOG_ERROR, "Error applying bitstream filters to an output " "packet for stream #%d:%d.\n", ost->file_index, ost->index); if(exit_on_error) exit_program(1); } }
1threat
How to call a class from a winform? : <p>Sorry I use this title on purpose. I m quite new on c# and i don't manage to call my class on the usual way.</p> <p>I have a winform and I want to insert a class (copy and paste from an API), and call it from my winform. </p> <p>This class is a program which open the console, ask me parameters and then lunch an EMG acquisition.</p> <p>the class is like that:</p> <pre><code> class Program1 { static void Main(string[] args) { // some code here, with a lot of "Console.Writeline" } } </code></pre> <p>It works fine.</p> <p>I change it to:</p> <pre><code> public class Program1 { public void method1(string[] args) { //some code here, , with a lot of "Console.Writeline" } } </code></pre> <p>And i tried to call it on my form </p> <pre><code> private void button1_Click(object sender, EventArgs e) { Program1 program = new Program1(); program.method1(); } </code></pre> <p>it says "No overload for method 'method1' takes 0 arguments" . The thing i don"t understand is when i run the program of the API alone it doesn't ask me anything it just runs. </p> <p>I'm pretty sure the error is from the <code>Console.WriteLine</code> and <code>Console.Readline</code> but i don't know how to resolve my problem. I want a button on my winform which run my class, open the console and ask me on the console which paramaters i want.</p> <p>Thank you !</p>
0debug
https://api.instagram.com/oauth/authorize api login error : <p>Instagram login API is in use. After approving the app, the following error occurs.</p> <p>The user denied your request.</p> <p>It worked well until yesterday. What's the problem?</p>
0debug
void ff_avg_h264_qpel4_mc32_msa(uint8_t *dst, const uint8_t *src, ptrdiff_t stride) { avc_luma_midh_qrt_and_aver_dst_4w_msa(src - (2 * stride) - 2, stride, dst, stride, 4, 1); }
1threat
static int virtio_net_handle_offloads(VirtIONet *n, uint8_t cmd, struct iovec *iov, unsigned int iov_cnt) { VirtIODevice *vdev = VIRTIO_DEVICE(n); uint64_t offloads; size_t s; if (!((1 << VIRTIO_NET_F_CTRL_GUEST_OFFLOADS) & vdev->guest_features)) { return VIRTIO_NET_ERR; } s = iov_to_buf(iov, iov_cnt, 0, &offloads, sizeof(offloads)); if (s != sizeof(offloads)) { return VIRTIO_NET_ERR; } if (cmd == VIRTIO_NET_CTRL_GUEST_OFFLOADS_SET) { uint64_t supported_offloads; if (!n->has_vnet_hdr) { return VIRTIO_NET_ERR; } supported_offloads = virtio_net_supported_guest_offloads(n); if (offloads & ~supported_offloads) { return VIRTIO_NET_ERR; } n->curr_guest_offloads = offloads; virtio_net_apply_guest_offloads(n); return VIRTIO_NET_OK; } else { return VIRTIO_NET_ERR; } }
1threat
int ff_framesync_request_frame(FFFrameSync *fs, AVFilterLink *outlink) { AVFilterContext *ctx = outlink->src; int input, ret; if ((ret = ff_framesync_process_frame(fs, 0)) < 0) return ret; if (ret > 0) return 0; if (fs->eof) return AVERROR_EOF; input = fs->in_request; ret = ff_request_frame(ctx->inputs[input]); if (ret == AVERROR_EOF) { if ((ret = ff_framesync_add_frame(fs, input, NULL)) < 0) return ret; if ((ret = ff_framesync_process_frame(fs, 0)) < 0) return ret; ret = 0; } return ret; }
1threat
Are Amazon Lightsail instances managed / automatically updated? : <p>I have been looking into Amazon Lightsail, but there is one thing that I haven't been able to find any information on.</p> <p>Are instances managed and updated automatically? In particular, I thinking of OS / web server security updates.</p> <p>With EC2, I have to log in every now and then to perform OS upgrades, updates and install security patches. This is fine for EC2, but I am now looking to set up a VPS that I can essentially install and forget, system-wise at least.</p> <p>Apologies if this is on the wrong site, but there is an <a href="/questions/tagged/amazon-lightsail" class="post-tag" title="show questions tagged &#39;amazon-lightsail&#39;" rel="tag">amazon-lightsail</a> tag here after all.</p>
0debug
Whot is wrong in sql : Whot is wrong in sql CONCAT(title, ', from ', CONVERT(DATETIME,CONVERT(NVARCHAR,startdate,107)), ' to ', CONVERT(DATETIME,CONVERT(NVARCHAR,end_date,107)), ' (', duration , ')') I want to change datetime to Sep 25, 2018 format
0debug
querrying these three tables : want to query these three tables and count the number of household in a community that have machinery id of 1 from these three tables machinery [hhmachineryid - hhid - machineryid] 1 10-10-009-0001 7 1 10-07-005-0001 7 2 10-02-054-0001 3 household table [ hhid- hh_comm_code ] 10-01-001-0001 10-01-001 10-01-001-0002 10-01-001 community table [ communitycode - community] 10-01-001 sekondi
0debug
Echo a variable's value inside a variable? : I need to echo the value of $sourceName. Searched a lot and tried this way but didn't work for me: $sourceName = '<p class="description">123'.$query.'</p class="description">'; <?php echo '<div id="listings" class="listings"> <strong></strong> '.$$sourceName.' </div>'; It can't get $query value and the code only echos: "123"
0debug
How to specify which domain using ngrok : <p>I use mamp and I have virtual hosts all on port 8888. For example:</p> <ul> <li>site1.dev:8888</li> <li>site2.dev:8888</li> </ul> <p>would point to <code>localhost/site1/</code>, <code>localhost/site2/</code> etc.</p> <p>Before using virtual hosts, I would just change my docroot to whatever project I was currently working on and would start ngrok like so</p> <p><code>./ngrok http 8888</code> and it would launch and give me a random generated *.ngrok.io url.</p> <p>My question is how do I specify the domain now since I am using virtual hosts?</p> <p>I've tried <code>./ngrok http site1.dev:8888</code> and it starts but just serves up mamps webroot.</p> <p>I am using a free account.</p>
0debug
static int get_int32_equal(QEMUFile *f, void *pv, size_t size) { int32_t *v = pv; int32_t v2; qemu_get_sbe32s(f, &v2); if (*v == v2) { return 0; } return -EINVAL; }
1threat
C# substring text of a textbox and datetime picker to a maskbox : I use to generate the permanent code with a button after I entered everything. like so: mskCodePer.Text = txtNom.Text.Substring(0, 3) + txtPrenom.Text.Substring(0, 1) + dptNaisc.Text.Substring(8, 2) + dptNaisc.Text.Substring(4, 4) + dptNaisc.Text.Substring(2, 3); But my teacher force me to do it in a way that it happens automatically as I type, but I don't understand how.... I tried to code into the textchanged event but each time I only get to type one letter, it crash and tells me the ArgumentOutOfRangeException has not been generated
0debug
Get the number of fields on an index : <p>For optimization purposes, I am trying to cut down my total field count. However before I am going to do that I want to get an idea of how many fields I actually have. There doesn't seem to be any Information in the <code>_stats</code> endpoint and I can't quite figure out how the migration tool does its field count calculation.</p> <p>Is there some way, either with an endpoint or by other means, to get the total field count of a specified index?</p>
0debug
Android: app crashing after launch activity : <p>I have this app but for some reason I can't get it to work past the launch screen. After a user clicks an item on the listview it generates a random int in the activity and based on that changes the textView. If the user's input matches the right .contains strings it'll print out a toast. Here is the launch activity: package com.eoincoogan.owner.omegaphi;</p> <pre><code>import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.ListView; public class LaunchActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_launch); ListView lv = (ListView) findViewById(R.id.subjectListView); String[] subjectArray = new String[]{"Physics","Chemistry","Economics", "Geography"}; ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_list_item_1, subjectArray); lv.setAdapter(adapter); lv.setOnItemClickListener( new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) { if (position == 0) { Intent intent = new Intent(LaunchActivity.this, PhysicsFragment.class); startActivity(intent); } else if (position == 1) { Intent intent = new Intent(LaunchActivity.this, ChemFragment.class); startActivity(intent); } else if (position == 2) { Intent intent = new Intent(LaunchActivity.this, EconFragment.class); startActivity(intent); } else if (position == 3) { Intent intent = new Intent(LaunchActivity.this, GeoActivity.class); startActivity(intent); } } } ); } } </code></pre> <p>Here is the activity after the LaunchActivity: package com.eoincoogan.owner.omegaphi;</p> <pre><code>import android.content.Intent; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; import android.widget.Toast; import java.util.Random; public class PhysicsFragment extends AppCompatActivity { private TextView definitionTextView = (TextView) findViewById(R.id.definitonTextView); String definitionText = definitionTextView.getText().toString(); private EditText userInputText = (EditText) findViewById(R.id.userInputText); String userInput = userInputText.getText().toString(); Random rand = new Random(); int value = rand.nextInt(3); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_physics_fragment); Button button = (Button)findViewById(R.id.button); Button buttonTwo = (Button)findViewById(R.id.button2); final Toast firstToast = Toast.makeText(this, "Correct", Toast.LENGTH_LONG); final Toast secondToast = Toast.makeText(this, "Correct", Toast.LENGTH_LONG); button.setOnClickListener( new Button.OnClickListener() { public void onClick(View v) { switch (value) { case 0: definitionText = "Diode"; if (userInput.contains("Current" + "one way" + "allows")) { firstToast.show(); } else { secondToast.show(); } case 1: definitionText = "First law of refraction"; if (userInput.contains("insidence" + "normal" + "refracted" + "ray")) { firstToast.show(); } else { secondToast.show(); } case 2: definitionText = "Second law of refraction"; if (userInput.contains("angle" + "incidence" + "reflection" + "equal")) { firstToast.show(); } else { secondToast.show(); } } Intent intent = getIntent(); finish(); startActivity(intent); } } ); //button to launch screen// buttonTwo.setOnClickListener( new Button.OnClickListener(){ @Override public void onClick(View v) { Intent myIntent = new Intent(PhysicsFragment.this, LaunchActivity.class); startActivity(myIntent); } } ); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.menu_driver, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } } </code></pre> <p>Any help would be much appreciated.</p>
0debug
static int net_slirp_init(VLANState *vlan, const char *model, const char *name) { if (!slirp_inited) { slirp_inited = 1; slirp_init(slirp_restrict, slirp_ip); } slirp_vc = qemu_new_vlan_client(vlan, model, name, slirp_receive, NULL, NULL, NULL); slirp_vc->info_str[0] = '\0'; return 0; }
1threat
How to remove 2 last characters with preg_replace : I have a code like : 784XX . XX could be a character or number. and i need a expression to remove the last 2 characters (XX) using ( and only ) **preg_replace**. How can i do that? For example, the output of : 782A3 is 782, 12122 is 121, 6542A is 654, 333CD is 333,
0debug
libAVFilter_QueryVendorInfo(libAVFilter *this, wchar_t **info) { dshowdebug("libAVFilter_QueryVendorInfo(%p)\n", this); if (!info) return E_POINTER; *info = wcsdup(L"libAV"); return S_OK; }
1threat
Detect is site opened in iframe and redirect : <p>there is a web app. It suppouse to be avilable only in specific iframe (corp. site), so uninvited guests are redirect to clients web site by script. Code below is working, but java could be disable in browser. IP white list would be a great solution, but too many dynamic IP is used.</p> <p>What php trick can be used to check is site opened in iframe?</p> <pre><code>&lt;script&gt; if (top === self) window.location.replace('http://uninvited-guests-go.here'); &lt;/script&gt; &lt;?php header('X-Frame-Options: ALLOW-FROM https://iframe.allow.only'); ?&gt; </code></pre>
0debug
How to convert STRING VALUE into an STRING VARIABLE : My question is suppose there is a String variable like String abc="Shini"; So is it possible to use 'Shini' as new variable name by some automatic means not by explicit typing. String abc="Shini"; String Shini="somevale";
0debug
How to change the color of card view on cliking it in android : <p>I want to change the background color of cardview whenever user clicks on it. Can anyone suggest me a way to do that? </p>
0debug
static void adx_encode(unsigned char *adx,const short *wav, ADXChannelState *prev) { int scale; int i; int s0,s1,s2,d; int max=0; int min=0; int data[32]; s1 = prev->s1; s2 = prev->s2; for(i=0;i<32;i++) { s0 = wav[i]; d = ((s0<<14) - SCALE1*s1 + SCALE2*s2)/BASEVOL; data[i]=d; if (max<d) max=d; if (min>d) min=d; s2 = s1; s1 = s0; } prev->s1 = s1; prev->s2 = s2; if (max==0 && min==0) { memset(adx,0,18); return; } if (max/7>-min/8) scale = max/7; else scale = -min/8; if (scale==0) scale=1; AV_WB16(adx, scale); for(i=0;i<16;i++) { adx[i+2] = ((data[i*2]/scale)<<4) | ((data[i*2+1]/scale)&0xf); } }
1threat
static void handle_qmp_command(JSONMessageParser *parser, QList *tokens) { Error *local_err = NULL; QObject *obj, *data; QDict *input, *args; const mon_cmd_t *cmd; const char *cmd_name; Monitor *mon = cur_mon; args = input = NULL; data = NULL; obj = json_parser_parse(tokens, NULL); if (!obj) { qerror_report(QERR_JSON_PARSING); goto err_out; } input = qmp_check_input_obj(obj, &local_err); if (!input) { qerror_report_err(local_err); qobject_decref(obj); goto err_out; } mon->mc->id = qdict_get(input, "id"); qobject_incref(mon->mc->id); cmd_name = qdict_get_str(input, "execute"); trace_handle_qmp_command(mon, cmd_name); cmd = qmp_find_cmd(cmd_name); if (!cmd) { qerror_report(ERROR_CLASS_COMMAND_NOT_FOUND, "The command %s has not been found", cmd_name); goto err_out; } if (invalid_qmp_mode(mon, cmd)) { goto err_out; } obj = qdict_get(input, "arguments"); if (!obj) { args = qdict_new(); } else { args = qobject_to_qdict(obj); QINCREF(args); } qmp_check_client_args(cmd, args, &local_err); if (local_err) { qerror_report_err(local_err); goto err_out; } if (cmd->mhandler.cmd_new(mon, args, &data)) { if (!monitor_has_error(mon)) { qerror_report(QERR_UNDEFINED_ERROR); } } err_out: monitor_protocol_emitter(mon, data); qobject_decref(data); QDECREF(input); QDECREF(args); }
1threat
How to handle changing parquet schema in Apache Spark : <p>I have run into a problem where I have Parquet data as daily chunks in S3 (in the form of <code>s3://bucketName/prefix/YYYY/MM/DD/</code>) but I cannot read the data in AWS EMR Spark from different dates because some column types do not match and I get one of many exceptions, for example:</p> <pre><code>java.lang.ClassCastException: optional binary element (UTF8) is not a group </code></pre> <p>appears when in some files there's an array type which has a value but the same column may have <code>null</code> value in other files which are then inferred as String types.</p> <p>or</p> <pre><code>org.apache.spark.SparkException: Job aborted due to stage failure: Task 23 in stage 42.0 failed 4 times, most recent failure: Lost task 23.3 in stage 42.0 (TID 2189, ip-172-31-9-27.eu-west-1.compute.internal): org.apache.spark.SparkException: Failed to merge incompatible data types ArrayType(StructType(StructField(Id,LongType,true), StructField(Name,StringType,true), StructField(Type,StringType,true)),true) </code></pre> <p>I have raw data in S3 in JSON format and my initial plan was to create an automatic job, which starts an EMR cluster, reads in the JSON data for the previous date and simply writes it as parquet back to S3.</p> <p>The JSON data is also divided into dates, i.e. keys have date prefixes. Reading JSON works fine. Schema is inferred from the data no matter how much data is currently being read.</p> <p>But the problem rises when parquet files are written. As I understand, when I write parquet with metadata files, these files contain the schema for all parts/partitions of the parquet files. Which, to me it seems, can also be with different schemas. When I disable writing metadata, Spark was said to infer the whole schema from the first file within the given Parquet path and presume it stays the same through other files.</p> <p>When some columns, which should be <code>double</code> type, have only integer values for a given day, reading in them from JSON (which has these numbers as integers, without floating points) makes Spark think it is a column with type <code>long</code>. Even if I can cast these columns to double before writing the Parquet files, this still is not good as the schema might change, new columns can be added, and tracking this is impossible. </p> <p>I have seen some people have the same problems but I have yet to find a good enough solution. </p> <p>What are the best practices or solutions for this? </p>
0debug
int avpriv_adx_decode_header(AVCodecContext *avctx, const uint8_t *buf, int bufsize, int *header_size, int *coeff) { int offset, cutoff; if (bufsize < 24) return AVERROR_INVALIDDATA; if (AV_RB16(buf) != 0x8000) return AVERROR_INVALIDDATA; offset = AV_RB16(buf + 2) + 4; if (bufsize >= offset && memcmp(buf + offset - 6, "(c)CRI", 6)) return AVERROR_INVALIDDATA; if (buf[4] != 3 || buf[5] != 18 || buf[6] != 4) { avpriv_request_sample(avctx, "Support for this ADX format"); return AVERROR_PATCHWELCOME; } avctx->channels = buf[7]; if (avctx->channels <= 0 || avctx->channels > 2) return AVERROR_INVALIDDATA; avctx->sample_rate = AV_RB32(buf + 8); if (avctx->sample_rate < 1 || avctx->sample_rate > INT_MAX / (avctx->channels * BLOCK_SIZE * 8)) return AVERROR_INVALIDDATA; avctx->bit_rate = avctx->sample_rate * avctx->channels * BLOCK_SIZE * 8 / BLOCK_SAMPLES; if (coeff) { cutoff = AV_RB16(buf + 16); ff_adx_calculate_coeffs(cutoff, avctx->sample_rate, COEFF_BITS, coeff); } *header_size = offset; return 0; }
1threat
Why does lspci lists pcie devices? : <p>When I do <code>lspci</code> I can see my nvme ssds. Why is that? Aren't PCI buses supposed to be separate from PCIe buses?</p>
0debug
Selenium: Find only visible elements by ClassName - Java : <p>I have a couple of elements of the same class in a single page, and I would like to move to each one of them and then do some stuff with it.</p> <p>I know how to get there(to the element), but I don't know how to access only the element that is seen. Any help ?</p>
0debug
document.write(smth) doesnt work : I want to add a button on the page in the script but it doesnt work. I cant do this in html because Please help! <script type="text/javascript"> document.write(' <p>Sign in</p> <form action="/chat" method="GET"> <p> Login: <input type="text" name="login"/> </p> <p> Password: <input type="text" name="password"/> <input type="submit" value="Ok"> </p> </form> <br> <form action="/signup"> <button type = "submit"> button for registration</button> </form>');
0debug
Hello, I need help on creating a Star Wars name generator using specific instructions. : I'm struggling with a specific method which takes in a String parameter. The promptString method will print its parameter to the user as a prompt, and then return a String that is the result of reading the console via the nextLine() method. For this program you will use nextLine() exclusively. I've prompted the user with a question using a parameter, and then used nextLine to read the string but after that im a bit lost how can i get the method to print to the console, i seem to only be able to return which only stores the string. import java.util.*; public class StarWarsName{ public static void main(String[]args){ promptString("Enter your first name: "); } public static String promptString(String n){ Scanner console = new Scanner(System.in); String first = console.nextline(); return first.trim(); } }
0debug
I am having an issue displaying Clip-Path on iphone chrome/safari browser : <p>I have created a test project at <a href="http://secretchickens.com/" rel="nofollow noreferrer">http://secretchickens.com/</a> using clip-paths to adjust the background. It works great on computer browsers, but on my iPhone with chrome/safari I can't see the clip-path. Do I need to do anything to make this work?</p>
0debug
Passing an *os.File as an *io.Reader : <p>If there's a function that takes a *io.Reader, how would one pass an *io.File? This doesn't work:</p> <pre><code>func somefunc(r *io.Reader){ } func Test_FileReader(t *testing.T){ f, err := os.Open("xyz") assert.NoError(t, err) somefunc(&amp;f) } </code></pre> <p>It gives this error:</p> <blockquote> <p>Cannot use '&amp;f' (type **File) as type *io.Reader</p> </blockquote> <p>Then, changing <code>*io.Reader</code>-><code>io.Reader</code> and <code>&amp;f</code>-><code>f</code>, it compiles just fine:</p> <pre><code>func somefunc(r io.Reader){ } func Test_FileReader(t *testing.T){ f, err := os.Open("xyz") assert.NoError(t, err) somefunc(f) } </code></pre> <p>Is it even possible to pass an *os.File as an *io.Reader??</p>
0debug
convert vba macro to google sheets : i need a way to translate a vba excel macro to google sheets, the code below transfers a list of data to an invoice and then saves it as a pdf i searched online for a translator but didn't find it if some one knows one or if some one can translate this one. thank you in advance Private Sub CommandButton1_Click() 'define value Dim customer As String Dim invoicenumber As Long Dim invoicedate As Long Dim path As String Dim myfilename As String Dim rate As Long Dim r As Long 'define our last row lastrow = Sheets("Dispatch1").Range("O" & Rows.Count).End(xlUp).Row ' start at row 5 r = 5 For r = 5 To 10 If Cells(r, 1).Value = "done" Then GoTo nextrow invoicedate = Sheets("Dispatch1").Cells(r, 5).Value rate = Sheets("Dispatch1").Cells(r, 15).Value invoicenumber = Sheets("Dispatch1").Cells(r, 17).Value Amount = Sheets("Dispatch1").Cells(r, 19).Value Application.DisplayAlerts = False Sheets("invoiceblank").Select ' map the variables to invoice worksheet data ActiveSheet.Range("F4").Value = invoicedate ActiveSheet.Range("G4").Value = invoicenumber ActiveSheet.Range("F18").Value = rate path = "C:\Users\Dell\Desktop\feb" ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _ fileName:="C:\Users\Dell\Desktop\aa new trucking\feb\" & _ ActiveSheet.Range("G4 ").Value & _ Worksheets("Customers").Range("A1").Value & _ ActiveSheet.Range("A16").Value & ".pdf", _ OpenAfterPublish:=False 'our label next row. Labels have a colon after their name nextrow: Next r End Sub
0debug
Returning JSON object that has an element in an array : I want to bring back the error associated with the field 'firstname' but I can't figure out how to reference the correct branch of the json. <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-js --> { "_original":{ "firstname":"1", "lastname":"1", "email":"1@1.com", "password":"1" }, "details":[ { "message":"\"firstname\" length must be at least 3 characters long", "path":[ "firstname" ], "type":"string.min", "context":{ "limit":3, "value":"1", "label":"firstname", "key":"firstname" } }, { "message":"\"lastname\" length must be at least 3 characters long", "path":[ "lastname" ], "type":"string.min", "context":{ "limit":3, "value":"1", "label":"lastname", "key":"lastname" } } ] } <!-- end snippet --> How do I return the indented object in the details array? I am searching on path:["firstname"]
0debug
Fixed time format for textbox : <p>I have a textBox1 which should take Fixed Format like eg below</p> <p>HH:MM:SS or <strong>:</strong>:__</p> <p>where HH,MM,SS can be entered but colon(:) should be fixed.Please help me out.</p>
0debug
static CadenceTimerState *cadence_timer_from_addr(void *opaque, target_phys_addr_t offset) { unsigned int index; CadenceTTCState *s = (CadenceTTCState *)opaque; index = (offset >> 2) % 3; return &s->timer[index]; }
1threat
const char *get_register_name_32(unsigned int reg) { if (reg > CPU_NB_REGS32) { return NULL; } return x86_reg_info_32[reg].name; }
1threat
Are these statements equivalent?: import package vs from package import * : <p>Are these statements equivalent?:</p> <p><code>import math</code> and <code>from math import *</code></p>
0debug
What is the difference between @types.coroutine and @asyncio.coroutine decorators? : <p>Documentations say:</p> <blockquote> <p>@asyncio.coroutine</p> <p>Decorator to mark generator-based coroutines. This enables the generator use yield from to call async def coroutines, and also enables the generator to be called by async def coroutines, for instance using an await expression.</p> </blockquote> <p>_</p> <blockquote> <p>@types.coroutine(gen_func) </p> <p>This function transforms a generator function into a coroutine function which returns a generator-based coroutine. The generator-based coroutine is still a generator iterator, but is also considered to be a coroutine object and is awaitable. However, it may not necessarily implement the <code>__await__()</code> method.</p> </blockquote> <p>So is seems like purposes is the same - to flag a generator as a coroutine (what <code>async def</code>in Python3.5 and higher does with some features).</p> <p>When need to use <code>asyncio.coroutine</code> when need to use <code>types.coroutine</code>, what is the diffrence?</p>
0debug
jQuery Validation Input value not begining with multiple paterns : <p>I started using jQuery validation on this new project I'm working on, and I've been struggling to find a rule to validate if a text input doesn't start "057" or "089" or "093.</p> <p>I know there is a notEqual rule that matches the whole input value, is there any way I can achieve the same but only for the first 3 characters?</p>
0debug
static void aio_timerlist_notify(void *opaque) { aio_notify(opaque); }
1threat
Permutation of a value by another R studio : I am working in R Studio with a database that has these two variables. Camouflage and Detection. The values are binary, 0 for being conspicuous and 1 for being camouflaged. 1 for detected and 0 for undetected. However, during my analysis I added values that are called Unknown in the Detection variable. I would like to permute the Unknown with 1 then 0 and see if each of the permutations affects the significance of the glm that I am using. The permutation may be that all Unknown change to 0 or to 1, or that some change to 1 and others to 0. A random permutation. It may be simple, it's just that I am not really functional with R. Thank you!
0debug
av_cold int ff_ac3_encode_init(AVCodecContext *avctx) { AC3EncodeContext *s = avctx->priv_data; int ret, frame_size_58; s->avctx = avctx; s->eac3 = avctx->codec_id == AV_CODEC_ID_EAC3; ff_ac3_common_init(); ret = validate_options(s); if (ret) return ret; avctx->frame_size = AC3_BLOCK_SIZE * s->num_blocks; avctx->delay = AC3_BLOCK_SIZE; s->bitstream_mode = avctx->audio_service_type; if (s->bitstream_mode == AV_AUDIO_SERVICE_TYPE_KARAOKE) s->bitstream_mode = 0x7; s->bits_written = 0; s->samples_written = 0; frame_size_58 = (( s->frame_size >> 2) + ( s->frame_size >> 4)) << 1; s->crc_inv[0] = pow_poly((CRC16_POLY >> 1), (8 * frame_size_58) - 16, CRC16_POLY); if (s->bit_alloc.sr_code == 1) { frame_size_58 = (((s->frame_size+2) >> 2) + ((s->frame_size+2) >> 4)) << 1; s->crc_inv[1] = pow_poly((CRC16_POLY >> 1), (8 * frame_size_58) - 16, CRC16_POLY); } if (CONFIG_AC3_FIXED_ENCODER && s->fixed_point) { s->mdct_end = ff_ac3_fixed_mdct_end; s->mdct_init = ff_ac3_fixed_mdct_init; s->allocate_sample_buffers = ff_ac3_fixed_allocate_sample_buffers; } else if (CONFIG_AC3_ENCODER || CONFIG_EAC3_ENCODER) { s->mdct_end = ff_ac3_float_mdct_end; s->mdct_init = ff_ac3_float_mdct_init; s->allocate_sample_buffers = ff_ac3_float_allocate_sample_buffers; } if (CONFIG_EAC3_ENCODER && s->eac3) s->output_frame_header = ff_eac3_output_frame_header; else s->output_frame_header = ac3_output_frame_header; set_bandwidth(s); exponent_init(s); bit_alloc_init(s); ret = s->mdct_init(s); if (ret) goto init_fail; ret = allocate_buffers(s); if (ret) goto init_fail; ff_audiodsp_init(&s->adsp); ff_me_cmp_init(&s->mecc, avctx); ff_ac3dsp_init(&s->ac3dsp, avctx->flags & CODEC_FLAG_BITEXACT); dprint_options(s); return 0; init_fail: ff_ac3_encode_close(avctx); return ret; }
1threat
Redis Installation fails when running make command : <h2>Redis installation on RHEL fails when running make command. Below is the output</h2> <pre><code>cd src &amp;&amp; make all make[1]: Entering directory `/root/Downloads/redis-3.2.0/src' CC adlist.o In file included from adlist.c:34: zmalloc.h:50:31: error: jemalloc/jemalloc.h: No such file or directory zmalloc.h:55:2: error: #error "Newer version of jemalloc required" make[1]: *** [adlist.o] Error 1 make[1]: Leaving directory `/root/Downloads/redis-3.2.0/src' make: *** [all] Error 2 </code></pre>
0debug
Initialized array by indices of elements in ascending order : <p>I have 2 arrays in C program. A1, A2 with size 1500, 780 respectively. Type of each array is integer (int). How can I initialized A1 by the indices of elements in ascending order, A2 - by the indices too, but in descending order?.</p> <pre><code>int A1[1500] int A2[780] </code></pre>
0debug
windows memory formatting issue for quality standards, yes quality standards : I am trying to make this dynamic reallocation work in a potable fashion. I have this code which works clean on linux but when I run it on windows it emits garbage. Does anyone know why/how to make this portable only using malloc. IE not using string.h(strcpy) str... anything but len. If you don't understand why please don't answer this question. If you code in csharp, get a life, and please don't answer. c17 only - no broken stucts(not portable). here is my code. Compiles with no errors gcc 7.3, mingw 7.3. I replace gets and puts with safer functions and I still get garbage on windows. I assume this is a formatting issue... #include <stdio.h> #include <stdlib.h> #include <string.h> #include <malloc.h> void wbuff (message) char *message; { FILE *f = fopen("file.txt", "w"); fprintf(f, "%s", message); fclose(f); } char *rean (message) char *message; { /* performs (write) on buffer, trims lefover, then restores */ char buf[80] = ""; puts("enter a line"); gets(buf); int bln = strlen( buf ); int mln = strlen( message ); int nln = bln + mln; printf("new length %d\n", nln); message = realloc(message, nln); memmove(message + mln, buf, bln); /* MISTAKE IS HERE?! */ if( nln >= 20 ) { int exl = nln -20; // leftover length char *lo = realloc(NULL, exl); // leftover placeholder memmove(lo, message+20, exl); // copy leftover wbuff(message); // write clear buff message = realloc(NULL, nln); message = realloc(NULL, exl); // resize buffer memmove(message, lo, exl); // restore leftover } return message; } void main (void) { char *message = ""; message = realloc(NULL, 0); while ( 1 == 1 ) { message = rean( message ); puts(message); } return; }
0debug
AndroidManifest Package Name error : <blockquote> <p>error: attribute 'package' in tag is not a valid Android package name: 'com.familyfit.google.22pushups'. Message{kind=ERROR, text=error: attribute 'package' in tag is not a valid Android package name: 'com.familyfit.google.22pushups'., sources=[/Users/manlokwong/Desktop/familyfit/22-pushups-android/app/build/intermediates/manifests/full/debug/AndroidManifest.xml:2], original message=, tool name=Optional.of(AAPT)}</p> </blockquote> <p>I don't know why I cannot set this package name.<br> <code>com.familyfit.google.22pushups</code></p>
0debug
Make a VStack fill the width of the screen in SwiftUI : <p>Given this code :</p> <pre><code>import SwiftUI struct ContentView : View { var body: some View { VStack(alignment: .leading) { Text("Title") .font(.title) Text("Content") .lineLimit(nil) .font(.body) Spacer() } .background(Color.red) } } #if DEBUG struct ContentView_Previews : PreviewProvider { static var previews: some View { ContentView() } } #endif </code></pre> <p>It results in this interace:</p> <p><a href="https://i.stack.imgur.com/B87Ym.png" rel="noreferrer"><img src="https://i.stack.imgur.com/B87Ym.png" alt="preview"></a></p> <p>How can I make the <code>VStack</code> fill the width of the screen even if the labels/text components don't need the full width?</p> <p>A trick I've found is to insert an <em>empty</em> <code>HStack</code> in the structure like so:</p> <pre><code>VStack(alignment: .leading) { HStack { Spacer() } Text("Title") .font(.title) Text("Content") .lineLimit(nil) .font(.body) Spacer() } </code></pre> <p>Which yields the desired design:</p> <p><a href="https://i.stack.imgur.com/XK2cY.png" rel="noreferrer"><img src="https://i.stack.imgur.com/XK2cY.png" alt="desired output"></a></p> <p>Is there a better way?</p>
0debug
Grunt-eslint & enabling `--fix` flag to auto fix violations : <p>I know <code>eslint</code> CLI itself has a <code>--fix</code> flag, but I can't tell from the documentation how to use this via <code>eslintConfig</code> (in <code>package.json</code>) or in the grunt-eslint configuration in my Gruntfile.</p> <p>I have the following config in <code>package.json</code>:</p> <pre><code>"env": { "browser": true, "amd": true }, "extends": "eslint:recommended", </code></pre> <p>and invoke it via a <code>lint</code> task using this Grunt config:</p> <pre><code> eslint: { target: [ 'src/app/**/*.js' ], format: 'checkstyle' }, </code></pre> <p>How can I enable the <code>--fix</code> flag in this scenario?</p>
0debug
int tpm_register_driver(const TPMDriverOps *tdo) { int i; for (i = 0; i < TPM_MAX_DRIVERS; i++) { if (!be_drivers[i]) { be_drivers[i] = tdo; return 0; } } error_report("Could not register TPM driver"); return 1; }
1threat
Node NPM proxy authentication - how do I configure it? : <p>I'm new to Node and trying to install TypeScript using the following command:</p> <pre><code>npm install -g typescript </code></pre> <p>I get the following error:</p> <pre><code>if you are behind a proxy, please make sure that the 'proxy' config is set properly. </code></pre> <p>I have set my proxy using the following commands:</p> <pre><code>npm config set proxy http://Username:Pa55w0rd@proxyhostname npm config set https-proxy http://Username:Pa55w0rd@proxyhostname </code></pre> <p>and tried this also:</p> <pre><code>npm config set proxy http://"ninjadev:5trongP@ssw0rd"@proxy.some-bigcorp.com npm config set https-proxy http://"ninjadev:5trongP@ssw0rd"@proxy.some-bigcorp.com </code></pre> <p>But none of them work. I am working behind a copmpany proxy with authentication, so I think this is stopping me from connecting. I have added my username and password and this also didn't work.</p> <p>Does anyone have any idea how I can connect to npm whilst using the company proxy and authentication?</p> <p>Thanks</p>
0debug
Linq distinct columns plus count from datatable : <p>Would like to pull a distinct list based on server name and resource group but provide a channel count as well. Datatable example:</p> <pre><code>resourceGroup serverName circuitId channelId SIP win1234 0 1 SIP win1234 0 2 TDM win5678 0 35 TDM win5678 0 36 SIP win5678 4 47 TDM win1234 8 56 </code></pre> <p>With the expected results:</p> <pre><code>serverName resourceGroup channelCount win1234 SIP 2 win1234 TDM 1 win5678 SIP 1 win5678 TDM 2 </code></pre>
0debug
static void mxf_write_partition(AVFormatContext *s, int bodysid, int indexsid, const uint8_t *key, int write_metadata) { MXFContext *mxf = s->priv_data; AVIOContext *pb = s->pb; int64_t header_byte_count_offset; unsigned index_byte_count = 0; uint64_t partition_offset = avio_tell(pb); if (!mxf->edit_unit_byte_count && mxf->edit_units_count) index_byte_count = 85 + 12+(s->nb_streams+1)*6 + 12+mxf->edit_units_count*(11+mxf->slice_count*4); else if (mxf->edit_unit_byte_count && indexsid) index_byte_count = 80; if (index_byte_count) { index_byte_count += 16 + klv_ber_length(index_byte_count); index_byte_count += klv_fill_size(index_byte_count); } if (!memcmp(key, body_partition_key, 16)) { mxf->body_partition_offset = av_realloc(mxf->body_partition_offset, (mxf->body_partitions_count+1)* sizeof(*mxf->body_partition_offset)); mxf->body_partition_offset[mxf->body_partitions_count++] = partition_offset; } avio_write(pb, key, 16); klv_encode_ber_length(pb, 88 + 16 * mxf->essence_container_count); avio_wb16(pb, 1); avio_wb16(pb, 2); avio_wb32(pb, KAG_SIZE); avio_wb64(pb, partition_offset); if (!memcmp(key, body_partition_key, 16) && mxf->body_partitions_count > 1) avio_wb64(pb, mxf->body_partition_offset[mxf->body_partitions_count-2]); else if (!memcmp(key, footer_partition_key, 16) && mxf->body_partitions_count) avio_wb64(pb, mxf->body_partition_offset[mxf->body_partitions_count-1]); else avio_wb64(pb, 0); avio_wb64(pb, mxf->footer_partition_offset); header_byte_count_offset = avio_tell(pb); avio_wb64(pb, 0); avio_wb64(pb, index_byte_count); avio_wb32(pb, index_byte_count ? indexsid : 0); if (bodysid && mxf->edit_units_count && mxf->body_partitions_count) { avio_wb64(pb, mxf->body_offset); } else avio_wb64(pb, 0); avio_wb32(pb, bodysid); avio_write(pb, op1a_ul, 16); mxf_write_essence_container_refs(s); if (write_metadata) { int64_t pos, start; unsigned header_byte_count; mxf_write_klv_fill(s); start = avio_tell(s->pb); mxf_write_primer_pack(s); mxf_write_header_metadata_sets(s); pos = avio_tell(s->pb); header_byte_count = pos - start + klv_fill_size(pos); avio_seek(pb, header_byte_count_offset, SEEK_SET); avio_wb64(pb, header_byte_count); avio_seek(pb, pos, SEEK_SET); } avio_flush(pb); }
1threat
Keras model load_weights for Neural Net : <p>I'm using the Keras library to create a neural network in python. I have loaded the training data (txt file), initiated the network and "fit" the weights of the neural network. I have then written code to generate the output text. Here is the code:</p> <pre><code>#!/usr/bin/env python # load the network weights filename = "weights-improvement-19-2.0810.hdf5" model.load_weights(filename) model.compile(loss='categorical_crossentropy', optimizer='adam') </code></pre> <p>My problem is: on execution the following error is produced:</p> <pre><code> model.load_weights(filename) NameError: name 'model' is not defined </code></pre> <p>I have added the following but the error still persists: </p> <pre><code>from keras.models import Sequential from keras.models import load_model </code></pre> <p>Any help would be appreciated.</p>
0debug
void ff_avg_h264_qpel8_mc11_msa(uint8_t *dst, const uint8_t *src, ptrdiff_t stride) { avc_luma_hv_qrt_and_aver_dst_8x8_msa(src - 2, src - (stride * 2), stride, dst, stride); }
1threat
Hot to tell Symfony http_client to read .htccess : I have a php application made in symfony, it needs this .htaccess to to work: RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] RewriteCond %{HTTP:Authorization} ^(.*) RewriteRule .* - [e=HTTP_AUTHORIZATION:%1] now I am writing some functional test and looks like the client can't find the controller for the route, this is the code: $response = static::createClient()->request( 'POST', '/api/login_check', [ 'body' => [ 'username' => 'username', 'password' => 'secret123!#' ] ] ); when I run the test I get this error: 2020-01-13T11:53:54+00:00 [error] Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\NotFoundHttpException: "Unable to find the controller for path "/api/login_check". The route is wrongly configured." at /var/www/html/vendor/symfony/http-kernel/HttpKernel.php line 130 which is exactly the same error I use to have using postman before to add the .htaccess file. Is there a way to make the http_client read the .htaccess file? Or alternatively, how can I get rid of the .htaccess file? thanks
0debug
JS/jQuery match two sets of arrays containing rgb color values using if/else : So I can create an array with rgb color values such as: var atomArr = ['rgb(255, 255, 255)', 'rgb(255, 34, 0)', 'rgb(255, 34, 0)']; With out going into details, I can even assign an object's background-color with a value from the array. So why can't I take two similar arrays and check if both of them match (ordered match not necessary, but both arrays must contain the same values)? In the example below, both arrays have the exact same values (not in order), but always triggers false. var h2o = ['rgb(255, 255, 255)', 'rgb(255, 34, 0)', 'rgb(255, 34, 0)']; function Check(A) { var atomArr = ['rgb(255, 34, 0)', 'rgb(255, 255, 255)', 'rgb(255, 34, 0)']; var i, j; var totalmatches = 0; for (i = 0; i < atomArr.length; i++) { for (j = 0; j < A.length; ++j) { if (atomArr[i] === A[j]) { totalmatches++; } } } if (totalmatches == 3) { console.log("true"); } else { console.log("false"); } } Check(h2o); Thank you for your time and help!
0debug
static int matroska_parse_block(MatroskaDemuxContext *matroska, uint8_t *data, int size, int64_t pos, uint64_t cluster_time, uint64_t duration, int is_keyframe, int64_t cluster_pos) { uint64_t timecode = AV_NOPTS_VALUE; MatroskaTrack *track; int res = 0; AVStream *st; AVPacket *pkt; int16_t block_time; uint32_t *lace_size = NULL; int n, flags, laces = 0; uint64_t num; if ((n = matroska_ebmlnum_uint(matroska, data, size, &num)) < 0) { av_log(matroska->ctx, AV_LOG_ERROR, "EBML block data error\n"); return res; data += n; size -= n; track = matroska_find_track_by_num(matroska, num); if (size <= 3 || !track || !track->stream) { av_log(matroska->ctx, AV_LOG_INFO, "Invalid stream %"PRIu64" or size %u\n", num, size); return res; st = track->stream; if (st->discard >= AVDISCARD_ALL) return res; if (duration == AV_NOPTS_VALUE) duration = track->default_duration / matroska->time_scale; block_time = AV_RB16(data); data += 2; flags = *data++; size -= 3; if (is_keyframe == -1) is_keyframe = flags & 0x80 ? PKT_FLAG_KEY : 0; if (cluster_time != (uint64_t)-1 && (block_time >= 0 || cluster_time >= -block_time)) { timecode = cluster_time + block_time; if (track->type == MATROSKA_TRACK_TYPE_SUBTITLE && timecode < track->end_timecode) is_keyframe = 0; if (is_keyframe) av_add_index_entry(st, cluster_pos, timecode, 0,0,AVINDEX_KEYFRAME); track->end_timecode = FFMAX(track->end_timecode, timecode+duration); if (matroska->skip_to_keyframe && track->type != MATROSKA_TRACK_TYPE_SUBTITLE) { if (!is_keyframe || timecode < matroska->skip_to_timecode) return res; matroska->skip_to_keyframe = 0; switch ((flags & 0x06) >> 1) { case 0x0: laces = 1; lace_size = av_mallocz(sizeof(int)); lace_size[0] = size; case 0x1: case 0x2: case 0x3: assert(size>0); laces = (*data) + 1; data += 1; size -= 1; lace_size = av_mallocz(laces * sizeof(int)); switch ((flags & 0x06) >> 1) { case 0x1: { uint8_t temp; uint32_t total = 0; for (n = 0; res == 0 && n < laces - 1; n++) { while (1) { if (size == 0) { res = -1; temp = *data; lace_size[n] += temp; data += 1; size -= 1; if (temp != 0xff) total += lace_size[n]; lace_size[n] = size - total; case 0x2: for (n = 0; n < laces; n++) lace_size[n] = size / laces; case 0x3: { uint32_t total; n = matroska_ebmlnum_uint(matroska, data, size, &num); if (n < 0) { av_log(matroska->ctx, AV_LOG_INFO, "EBML block data error\n"); data += n; size -= n; total = lace_size[0] = num; for (n = 1; res == 0 && n < laces - 1; n++) { int64_t snum; int r; r = matroska_ebmlnum_sint(matroska, data, size, &snum); if (r < 0) { av_log(matroska->ctx, AV_LOG_INFO, "EBML block data error\n"); data += r; size -= r; lace_size[n] = lace_size[n - 1] + snum; total += lace_size[n]; lace_size[n] = size - total; if (res == 0) { for (n = 0; n < laces; n++) { if ((st->codec->codec_id == CODEC_ID_RA_288 || st->codec->codec_id == CODEC_ID_COOK || st->codec->codec_id == CODEC_ID_ATRAC3) && st->codec->block_align && track->audio.sub_packet_size) { int a = st->codec->block_align; int sps = track->audio.sub_packet_size; int cfs = track->audio.coded_framesize; int h = track->audio.sub_packet_h; int y = track->audio.sub_packet_cnt; int w = track->audio.frame_size; int x; if (!track->audio.pkt_cnt) { if (st->codec->codec_id == CODEC_ID_RA_288) for (x=0; x<h/2; x++) memcpy(track->audio.buf+x*2*w+y*cfs, data+x*cfs, cfs); else for (x=0; x<w/sps; x++) memcpy(track->audio.buf+sps*(h*x+((h+1)/2)*(y&1)+(y>>1)), data+x*sps, sps); if (++track->audio.sub_packet_cnt >= h) { track->audio.sub_packet_cnt = 0; track->audio.pkt_cnt = h*w / a; while (track->audio.pkt_cnt) { pkt = av_mallocz(sizeof(AVPacket)); av_new_packet(pkt, a); memcpy(pkt->data, track->audio.buf + a * (h*w / a - track->audio.pkt_cnt--), a); pkt->pos = pos; pkt->stream_index = st->index; dynarray_add(&matroska->packets,&matroska->num_packets,pkt); } else { MatroskaTrackEncoding *encodings = track->encodings.elem; int offset = 0, pkt_size = lace_size[n]; uint8_t *pkt_data = data; if (encodings && encodings->scope & 1) { offset = matroska_decode_buffer(&pkt_data,&pkt_size, track); if (offset < 0) continue; pkt = av_mallocz(sizeof(AVPacket)); if (av_new_packet(pkt, pkt_size+offset) < 0) { av_free(pkt); res = AVERROR(ENOMEM); if (offset) memcpy (pkt->data, encodings->compression.settings.data, offset); memcpy (pkt->data+offset, pkt_data, pkt_size); if (pkt_data != data) av_free(pkt_data); if (n == 0) pkt->flags = is_keyframe; pkt->stream_index = st->index; if (track->ms_compat) pkt->dts = timecode; else pkt->pts = timecode; pkt->pos = pos; if (st->codec->codec_id == CODEC_ID_TEXT) pkt->convergence_duration = duration; else if (track->type != MATROSKA_TRACK_TYPE_SUBTITLE) pkt->duration = duration; if (st->codec->codec_id == CODEC_ID_SSA) matroska_fix_ass_packet(matroska, pkt, duration); if (matroska->prev_pkt && timecode != AV_NOPTS_VALUE && matroska->prev_pkt->pts == timecode && matroska->prev_pkt->stream_index == st->index) matroska_merge_packets(matroska->prev_pkt, pkt); else { dynarray_add(&matroska->packets,&matroska->num_packets,pkt); matroska->prev_pkt = pkt; if (timecode != AV_NOPTS_VALUE) timecode = duration ? timecode + duration : AV_NOPTS_VALUE; data += lace_size[n]; size -= lace_size[n]; av_free(lace_size); return res;
1threat
Java, JFrame, 3D Perspective in 2D Space : I'm working in Java with its JFrame. I want to be able to draw 3D objects like a cube. But I have a problem, I don't know how to calculate the x and y position of where the vertices would go on the z axis. I'm not working in OpenGL or anything, just using java's built in features. I have the window set up and i'm able to draw lines, all I kneed to know to be able to get this to work is the calculation of where the position of vertices on the z axis would be placed in a 2D space. Thank you in advance for any help!
0debug
connection.query('SELECT * FROM users WHERE username = ' + input_string)
1threat
i cannot use my arraylist in class fragment : i try to use arraylist in fragment my arraylist not work in fragment class. please help me fix this before i use this code in main activity, and then i added menu fragment i move this code to this fragment and then my **arraylist** get error ``` public class HomeFragment extends Fragment { RecyclerView mRecyclerView; MyAdapter myAdapter; public HomeFragment() { // Required empty public constructor } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View v = inflater.inflate(R.layout.fragment_home, container, false); mRecyclerView = v.findViewById(R.id.recyclerView); mRecyclerView.setLayoutManager(new RelativeLayout(this)); myAdapter = new MyAdapter(this, getMyList()); mRecyclerView.setAdapter(myAdapter); return v; } private ArrayList<Model> getMyList(){ ArrayList<Model> models = new ArrayList<>(); Model m = new Model(); m.setTitle("Al-Lahab"); m.setDescription("Surah Al-Lahab adalah surat ke-111 dalam Al-Qur'an."); m.setDetails("ุชูŽุจู‘ูŽุชู’ ูŠูŽุฏูŽุง ุฃูŽุจููŠ ู„ูŽู‡ูŽุจู ูˆูŽุชูŽุจู‘\n" ); m.setImg(R.drawable.al_lahab); models.add(m); return models; } ```
0debug
static int x11grab_read_packet(AVFormatContext *s1, AVPacket *pkt) { X11GrabContext *s = s1->priv_data; Display *dpy = s->dpy; XImage *image = s->image; int x_off = s->x_off; int y_off = s->y_off; int follow_mouse = s->follow_mouse; int screen; Window root; int64_t curtime, delay; struct timespec ts; s->time_frame += INT64_C(1000000); for (;;) { curtime = av_gettime(); delay = s->time_frame * av_q2d(s->time_base) - curtime; if (delay <= 0) { if (delay < INT64_C(-1000000) * av_q2d(s->time_base)) s->time_frame += INT64_C(1000000); break; } ts.tv_sec = delay / 1000000; ts.tv_nsec = (delay % 1000000) * 1000; nanosleep(&ts, NULL); } av_init_packet(pkt); pkt->data = image->data; pkt->size = s->frame_size; pkt->pts = curtime; screen = DefaultScreen(dpy); root = RootWindow(dpy, screen); if (follow_mouse) { int screen_w, screen_h; int pointer_x, pointer_y, _; Window w; screen_w = DisplayWidth(dpy, screen); screen_h = DisplayHeight(dpy, screen); XQueryPointer(dpy, root, &w, &w, &pointer_x, &pointer_y, &_, &_, &_); if (follow_mouse == -1) { x_off += pointer_x - s->width / 2 - x_off; y_off += pointer_y - s->height / 2 - y_off; } else { if (pointer_x > x_off + s->width - follow_mouse) x_off += pointer_x - (x_off + s->width - follow_mouse); else if (pointer_x < x_off + follow_mouse) x_off -= (x_off + follow_mouse) - pointer_x; if (pointer_y > y_off + s->height - follow_mouse) y_off += pointer_y - (y_off + s->height - follow_mouse); else if (pointer_y < y_off + follow_mouse) y_off -= (y_off + follow_mouse) - pointer_y; } s->x_off = x_off = FFMIN(FFMAX(x_off, 0), screen_w - s->width); s->y_off = y_off = FFMIN(FFMAX(y_off, 0), screen_h - s->height); if (s->show_region && s->region_win) XMoveWindow(dpy, s->region_win, s->x_off - REGION_WIN_BORDER, s->y_off - REGION_WIN_BORDER); } if (s->show_region) { if (s->region_win) { XEvent evt = { .type = NoEventMask }; while (XCheckMaskEvent(dpy, ExposureMask | StructureNotifyMask, &evt)) ; if (evt.type) x11grab_draw_region_win(s); } else { x11grab_region_win_init(s); } } if (s->use_shm) { if (!XShmGetImage(dpy, root, image, x_off, y_off, AllPlanes)) av_log(s1, AV_LOG_INFO, "XShmGetImage() failed\n"); } else { if (!xget_zpixmap(dpy, root, image, x_off, y_off)) av_log(s1, AV_LOG_INFO, "XGetZPixmap() failed\n"); } if (s->draw_mouse) paint_mouse_pointer(image, s); return s->frame_size; }
1threat
Is there any easy way to merge two arrays in swift along with removing duplicates? : <p>Basically I need a version of <code>appendContentsOf:</code> which does not append <strong>duplicate</strong> elements.</p> <p><strong>Example</strong></p> <pre><code>var a = [1, 2, 3] let b = [3, 4, 5] a.mergeElements(b) //gives a = [1, 2, 3, 4, 5] //order does not matter </code></pre>
0debug
travis-ci โ€” Waiting for status to be reported : <p>I pushed a new commit to my git repo, but travis-ci build isn't triggered.</p> <p><a href="https://i.stack.imgur.com/DYs8x.png" rel="noreferrer"><img src="https://i.stack.imgur.com/DYs8x.png" alt="enter image description here"></a></p> <p>It show:</p> <blockquote> <p>continuous-integration/travis-ci โ€” Waiting for status to be reported</p> </blockquote> <p>but no job is running on travis-ci. It is so strange! </p> <p>Anyone has idea for this! Thanks in advance!</p>
0debug
How to fix ,,Extraneous argument label 'input:' in call" and sigrabitTHREAD1 problem in swift : I'm building calendar app in swift. It has got a sigrbrtTHREAD1 problem and that strang mistake. Sorry for probably silly question but I'm completely beginner. Here is the code: import UIKit class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view. var wydarzenia = ["Wydarzenie1", "Wydarzenie2" ] weak var input: UITextField! weak var output: UILabel! print(wydarzenia) func show(_ sender: UIButton) { print(wydarzenia) } func add(_ sender: UIButton) { wydarzenia.append (input: String). !Extraneous argument label 'input:' in call! } } } } }
0debug