title
stringlengths
15
150
body
stringlengths
38
32.9k
label
int64
0
3
Is there a way to add a class to the first word of a specific class?
<p>i'm looking for a way to add a custom class to the first and second word of a specific class ?</p> <p>My code goes like this </p> <pre><code>&lt;h2 class="content-heading"&gt;Latest News&lt;/h2&gt; </code></pre> <p>And i would like to have something like</p> <pre><code>&lt;h2 class="content-heading"&gt;&lt;span class="1"&gt;Latest&lt;/span&gt; &lt;span class="2"&gt;News&lt;/span&gt;&lt;/h2&gt; </code></pre>
2
Simulate data in JAGS/r2jags
<p>Is it possible to misuse JAGS as a tool for generating data from a model with known parameters? I need to sample data points from a predefined model in order to do a simulation study and test the power of a model I have developed in R.</p> <p>Unfortunately, the model is somehow tricky (hierarchical structure with AR and VAR component) and I was not able to simulate the data directly in R. While searching the internet, I found a <a href="http://www.georg-hosoya.de/wordpress/?p=799" rel="nofollow">blog post</a> where the data was generated in JAGS using the <code>data{}</code> Block in JAGS. In the post, the author than estimated the model directly in JAGS. Since I have my model in R, I would like to transfer the data back to R without a <code>model{}</code> block. Is this possible?</p> <p>Best, win</p>
2
How to add "+91" and remove "+91" in edit text in android?
<p>I have an activity in which I have mobile edit text what I want when user enter mobile number I want to add "+91" before number and when user delete full number I want to delete "+91" also .How can I do that</p> <pre><code>TextWatcher m_MobileWatcher = new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void afterTextChanged(Editable s) { if (!s.toString().contains("+91")) { m_InputMobie.setText("+91" + s.toString()); Selection.setSelection(m_InputMobie.getText(), m_InputMobie.getText().length()); } } }; </code></pre>
2
After macOS Sierra Update, Eject USB trigger hard-reset
<p>I'm using Android Studio and Samsung Galaxy S4. After updated macOS Sierra devPreview version. When I eject phone USB connection, my Retina MacBook Pro MID2015 freeze and not response. (Two times I encountered with this) I need to enforce hard-reset with keyboard hold power key. After restart it gives me below error.</p> <p>What does it mean? What I need to. I informed as bug report.</p> <pre><code>Tue Jun 28 12:53:54 2016 *** Panic Report *** panic(cpu 4 caller 0xffffff8002cb260e): Preemption level underflow, possible cause unlocking an unlocked mutex or spinlock Backtrace (CPU 4), Frame : Return Address 0xffffff9238053c00 : 0xffffff8002d0475c 0xffffff9238053c80 : 0xffffff8002cb260e 0xffffff9238053c90 : 0xffffff8002cb232f 0xffffff9238053ca0 : 0xffffff800329473b 0xffffff9238053cf0 : 0xffffff80032957a0 0xffffff9238053d40 : 0xffffff80032ed07e 0xffffff9238053db0 : 0xffffff8002dce792 0xffffff9238053e00 : 0xffffff8002d092e9 0xffffff9238053e40 : 0xffffff8002ce6eb1 0xffffff9238053e90 : 0xffffff8002cfaca1 0xffffff9238053f10 : 0xffffff8002dfa3b9 0xffffff9238053fb0 : 0xffffff8002cb5dc6 BSD process name corresponding to current thread: adb Mac OS version: 16A201w Kernel version: Darwin Kernel Version 16.0.0: Fri Jun 3 13:56:38 PDT 2016; root:xnu-3705.0.0.1.10~1/RELEASE_X86_64 Kernel UUID: 79D0A860-C130-3371-AB9B-3772AE60777B Kernel slide: 0x0000000002a00000 Kernel text base: 0xffffff8002c00000 __HIB text base: 0xffffff8002b00000 System model name: MacBookPro11,5 (Mac-06F11F11946D27C5) System uptime in nanoseconds: 19949337419569 last loaded kext at 18286149408268: com.devguru.driver.SamsungACMData 1.4.32 (addr 0xffffff7f87006000, size 86016) last unloaded kext at 17714940195824: com.apple.driver.AppleMikeyHIDDriver 127 (addr 0xffffff7f86f4a000, size 16384) loaded kexts: com.devguru.driver.SamsungACMData 1.4.32 com.devguru.driver.SamsungACMControl 1.4.32 com.devguru.driver.SamsungMTP 1.4.32 com.devguru.driver.SamsungComposite 1.4.32 com.intel.kext.intelhaxm 6.0.1 com.apple.filesystems.smbfs 3.1 com.apple.driver.AudioAUUC 1.70 com.apple.driver.AGPM 110.23.4 com.apple.driver.ApplePlatformEnabler 2.7.0d0 com.apple.driver.X86PlatformShim 1.0.0 com.apple.filesystems.autofs 3.0 com.apple.driver.AppleOSXWatchdog 1 com.apple.driver.AppleHDA 275.68 com.apple.driver.AppleGraphicsDevicePolicy 3.13.45 com.apple.driver.AppleUpstreamUserClient 3.6.1 com.apple.driver.pmtelemetry 1 com.apple.iokit.IOUserEthernet 1.0.1 com.apple.kext.AMDFramebuffer 1.4.4 com.apple.iokit.IOBluetoothSerialManager 5.0.0d59 com.apple.driver.AppleIntelHD5000Graphics 10.1.8 com.apple.AMDRadeonX4000 1.4.4 com.apple.Dont_Steal_Mac_OS_X 7.0.0 com.apple.driver.AppleHV 1 com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport 5.0.0d59 com.apple.driver.AppleThunderboltIP 3.0.8 com.apple.driver.AppleIntelFramebufferAzul 10.1.8 com.apple.driver.AppleSMCLMU 208 com.apple.driver.AppleLPC 3.1 com.apple.driver.AppleMuxControl 3.13.45 com.apple.driver.AppleCameraInterface 5.52.0 com.apple.kext.AMD7000Controller 1.4.4 com.apple.driver.AppleIntelSlowAdaptiveClocking 4.0.0 com.apple.driver.AppleMCCSControl 1.2.13 com.apple.driver.AppleUSBCardReader 396 com.apple.driver.AppleTopCaseHIDEventDriver 95 com.apple.driver.AppleUSBTopCaseDriver 95 com.apple.iokit.IOAHCIBlockStorage 292 com.apple.driver.AirPort.Brcm4360 1100.25.1a7 com.apple.driver.AppleAHCIPort 324 com.apple.AppleFSCompression.AppleFSCompressionTypeDataless 1.0.0d1 com.apple.AppleFSCompression.AppleFSCompressionTypeZlib 1.0.0 com.apple.BootCache 38 com.apple.filesystems.hfs.kext 360 com.apple.driver.AppleSmartBatteryManager 161.0.0 com.apple.driver.AppleRTC 2.0 com.apple.driver.AppleACPIButtons 5.0 com.apple.driver.AppleHPET 1.8 com.apple.driver.AppleSMBIOS 2.1 com.apple.driver.AppleACPIEC 5.0 com.apple.driver.AppleAPIC 1.7 com.apple.nke.applicationfirewall 165 com.apple.security.quarantine 3 com.apple.security.TMSafetyNet 8 com.apple.kext.triggers 1.0 com.apple.driver.DspFuncLib 275.68 com.apple.kext.OSvKernDSPLib 525 com.apple.iokit.IOSerialFamily 11 com.apple.iokit.IOSurface 141 com.apple.iokit.IOBluetoothHostControllerUSBTransport 5.0.0d59 com.apple.iokit.IOBluetoothHostControllerTransport 5.0.0d59 com.apple.iokit.IOBluetoothFamily 5.0.0d59 com.apple.iokit.IOAcceleratorFamily2 259 com.apple.driver.AppleHDAController 275.68 com.apple.iokit.IOHDAFamily 275.68 com.apple.iokit.IOAudioFamily 205.9 com.apple.vecLib.kext 1.2.0 com.apple.driver.AppleGraphicsControl 3.13.45 com.apple.driver.X86PlatformPlugin 1.0.0 com.apple.driver.IOPlatformPluginFamily 6.0.0d7 com.apple.kext.AMDSupport 1.4.4 com.apple.AppleGraphicsDeviceControl 3.13.45 com.apple.iokit.IOSlowAdaptiveClockingFamily 1.0.0 com.apple.driver.AppleBacklightExpert 1.1.0 com.apple.iokit.IONDRVSupport 2.4.1 com.apple.driver.AppleSMC 3.1.9 com.apple.driver.AppleSMBusController 1.0.14d1 com.apple.iokit.IOGraphicsFamily 2.4.1 com.apple.iokit.IOSCSIBlockCommandsDevice 391 com.apple.iokit.IOUSBMassStorageDriver 126.1.1 com.apple.iokit.IOSCSIArchitectureModelFamily 391 com.apple.driver.AppleHIDKeyboard 194 com.apple.driver.AppleMultitouchDriver 355.1.1 com.apple.driver.AppleInputDeviceSupport 69 com.apple.driver.usb.IOUSBHostHIDDevice 1.1 com.apple.driver.usb.networking 5.0.0 com.apple.driver.usb.AppleUSBHostCompositeDevice 1.1 com.apple.driver.CoreStorage 530 com.apple.iokit.IO80211Family 1200.12.2 com.apple.driver.mDNSOffloadUserClient 1.0.1b8 com.apple.driver.corecapture 1.0.4 com.apple.driver.usb.AppleUSBXHCIPCI 1.1 com.apple.driver.usb.AppleUSBXHCI 1.1 com.apple.iokit.IOAHCIFamily 287 com.apple.filesystems.hfs.encodings.kext 1 com.apple.iokit.IONetworkingFamily 3.2 com.apple.driver.AppleThunderboltDPInAdapter 4.5.2 com.apple.driver.AppleThunderboltDPAdapterFamily 4.5.2 com.apple.driver.AppleThunderboltPCIDownAdapter 2.0.3 com.apple.driver.AppleThunderboltNHI 4.1.1 com.apple.iokit.IOThunderboltFamily 6.1.3 com.apple.iokit.IOUSBFamily 900.4.1 com.apple.iokit.IOUSBHostFamily 1.1 com.apple.driver.AppleUSBHostMergeProperties 1.1 com.apple.driver.AppleEFINVRAM 2.0 com.apple.driver.AppleBusPowerController 1.0 com.apple.driver.AppleEFIRuntime 2.0 com.apple.iokit.IOHIDFamily 2.0.0 com.apple.iokit.IOSMBusFamily 1.1 com.apple.security.sandbox 300.0 com.apple.kext.AppleMatch 1.0.0d1 com.apple.driver.AppleKeyStore 2 com.apple.driver.AppleMobileFileIntegrity 1.0.5 com.apple.driver.AppleCredentialManager 1.0 com.apple.driver.DiskImages 439.2 com.apple.iokit.IOStorageFamily 2.1 com.apple.iokit.IOReportFamily 31 com.apple.driver.AppleFDEKeyStore 28.30 com.apple.driver.AppleACPIPlatform 5.0 com.apple.iokit.IOPCIFamily 2.9 com.apple.iokit.IOACPIFamily 1.4 com.apple.kec.Libm 1 com.apple.kec.pthread 1 com.apple.kec.corecrypto 1.0 Model: MacBookPro11,5, BootROM MBP114.0172.B09, 4 processors, Intel Core i7, 2,5 GHz, 16 GB, SMC 2.30f2 Graphics: AMD Radeon R9 M370X, AMD Radeon R9 M370X, PCIe, 2048 MB Graphics: Intel Iris Pro, Intel Iris Pro, Built-In Memory Module: BANK 0/DIMM0, 8 GB, DDR3, 1600 MHz, 0x80AD, 0x484D54343147533642465238412D50422020 Memory Module: BANK 1/DIMM0, 8 GB, DDR3, 1600 MHz, 0x80AD, 0x484D54343147533642465238412D50422020 AirPort: spairport_wireless_card_type_airport_extreme (0x14E4, 0x152), Broadcom BCM43xx 1.0 (7.21.149.34.1a7) Bluetooth: Version 5.0.0d59, 3 services, 27 devices, 1 incoming serial ports Network Service: Wi-Fi, AirPort, en0 Serial ATA Device: APPLE SSD SM0512G, 500,28 GB USB Device: USB 3.0 Bus USB Device: Apple Internal Keyboard / Trackpad USB Device: Bluetooth USB Host Controller Thunderbolt Bus: MacBook Pro, Apple Inc., 27.1 </code></pre>
2
Delete selected row column in DataGridView
<p>Can I delete the first column of a DataGridView? </p> <p><img src="https://i.stack.imgur.com/hDNMC.png" alt="enter image description here"></p>
2
WPF: binding to dependency property of a class that inherits a user control base class
<p>I have a user control in wpf named "GoogleMap.xaml/.cs" where the xaml declaration starts like this:</p> <pre><code>&lt;controls:BaseUserControl x:Class="CompanyNamespace.Controls.GoogleMap" </code></pre> <p>the code behind:</p> <pre><code> public partial class GoogleMap : BaseUserControl{ public static readonly DependencyProperty MapCenterProperty = DependencyProperty.Register("MapCenter", typeof(string), typeof(GoogleMap), new FrameworkPropertyMetadata(string.Empty, OnMapCenterPropertyChanged)); public string MapCenter { get { return (string)GetValue(MapCenterProperty); } set { SetValue(MapCenterProperty, value); } } private static void OnMapCenterPropertyChanged(DependencyObject source, DependencyPropertyChangedEventArgs e){ GoogleMap control = source as GoogleMap; control.SetCenter(e.NewValue.ToString()); } ... } </code></pre> <p>What's the correct syntax for me to be able to address the property from GoogleMap.xaml:</p> <pre><code>MapCenter="{Binding Location}" </code></pre> <p>I can only bind to this property from GoogleMap.xaml if I place the property is in the BaseUserControl class. </p> <p><strong>Update</strong> GoogleMapViewModel.cs</p> <pre><code>public class GoogleMapViewModel : ContainerViewModel{ private string location; [XmlAttribute("location")] public string Location { get { if (string.IsNullOrEmpty(location)) return appContext.DeviceGeolocation.Location(); return ExpressionEvaluator.Evaluate(location); } set { if (location == value) return; location = value; RaisePropertyChanged("Location"); } } </code></pre>
2
What exactly are LDFLAGS and CXXFLAGS?
<p>I have read for some installation, I need to set up environment variables LDFLAGS, LD_LIBRARY_PATHS and CXXFLAGS correctly for ./compile.sh to run. However, I am not sure what path to give there. Can someone please explain what those flags mean and what are they used for? Are they something related to the gcc installation? </p> <p>I am working on CENTOS 6.6 with default gcc 4.4.7 but I want to use gcc 4.9.1 which is installed in /opt/rh/devtoolset-3/root/usr/bin/gcc.</p> <p>I tried to look up other similar questions but did not get my answer. i want to know what exactly the paths/flags mean.</p> <p>I am new to Linux so please disregard my ignorance. Thank you.</p>
2
Setting width of iconContainer of StepperButton in react material-ui
<p>I'm using the callemall react material-ui Stepper component to good effect but there's one thing I can't seem to do: Within a Stepper you have Steps. Those Steps have StepButtons which can have an icon. The icon is within a span that gets the style: styles.iconContainer. </p> <p>Unfortunately the width there is hardcoded to 24px which is a problem if you want to have bigger icons. Try as I might I'm not able to override the width of said container. </p> <p>This leads to the following situation, I have a button with an Icon (bigger than normal) and some text underneath it. This works fine but the Icon doesn't get centered as the span containing it is too small.</p> <p>Looks like this (look at the second and third Icon, they are not centered): <a href="https://i.stack.imgur.com/cmK2y.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cmK2y.png" alt="uncentered"></a></p> <p>If I change the hardcoded width of 24px to 100% it looks like this (much better): <a href="https://i.stack.imgur.com/wwxdg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wwxdg.png" alt="centered"></a></p> <p>Unfortunately I can only achieve this if I change the code of the StepLabel component itself, something I don't want to do. The code that prepares the style looks like this:</p> <pre><code>var styles = { root: { height: orientation === 'horizontal' ? 72 : 64, color: textColor, display: 'flex', alignItems: 'center', fontSize: 14, paddingLeft: 14, paddingRight: 14 }, icon: { color: iconColor, display: 'block', fontSize: 24, width: 24, height: 24 }, iconContainer: { display: 'flex', alignItems: 'center', paddingRight: 8, width: 24 --&gt;this hardcoded thing is giving me headaches } </code></pre> <p>};</p> <p>So, does anyone have a suggestion on how I could override this specific style?</p> <p>Source for the StepLabel Component can be found at: <a href="https://github.com/callemall/material-ui/blob/master/src/Stepper/StepLabel.js" rel="nofollow noreferrer">GitHub | StepLabel</a> if you need to see it within context.</p>
2
(Polymer) Refreshing google-map after dynamically adding google-map-markers to DOM
<p>Currently using the google-map component for Polymer and having some issues. </p> <p><a href="https://elements.polymer-project.org/elements/google-map" rel="nofollow">https://elements.polymer-project.org/elements/google-map</a></p> <p>What I'm wanting to do is dynamically create google-map-markers to display on a map. This could be coordinates in the URL, data grabbed from our database, etc.</p> <p>This is what my code currently looks like below: </p> <pre><code>&lt;google-map id="map" fit-to-markers api-key="API-KEY"&gt; &lt;template is="dom-repeat" items="{{data}}"&gt; &lt;google-map-marker latitude="[[item.Latitude]]" longitude="[[item.Longitude]]"&gt;Marker&lt;/google-map-marker&gt; &lt;/template&gt; &lt;/google-map&gt; </code></pre> <p>Here's my issue, however. This ONLY works whenever the markers finish rendering to the DOM before the map is loaded. If the map loads first, the markers will not show up. So obviously, I'm hitting a race condition. </p> <p>Is there any way to refresh the google-map element to display the new markers after they've finished rendering to the DOM? I feel like I've tried every function on the element's page to no avail.</p> <p>Any help would be greatly appreciated.</p>
2
C# winforms best place where to check if user logged
<p>Guys in my winforms desktop application i have user logging system. Am not sure where to set logic to check if user is logged or not. If is logged show main window or if not logged show login form.</p> <p>First i try to avoid using database for logging because winforms does not support sessions. I crate static <code>User</code> class where i store super_admin credentials and that is enough for this app.</p> <p>So my first try is to set everything in main before mainWindow form is showed:</p> <p><strong>Program.cs</strong></p> <pre><code>[STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); if (!User.IsLogged) { Application.Run(new Login()); } Application.Run(new Login()); } </code></pre> <p>Or is better to set this inside <code>MainWindow</code> form inside constructor or in <code>Load</code>? Or Maybe inside static <code>MainWindow</code> constuctor? MainWindow is mdi! </p> <p>So can you suggest me what is better way?</p> <p>Here is static (User.cs):</p> <pre><code>private static string superAdminUsername = "admin"; private static string superAdminPassword = "123"; public static bool IsLogged { get { return isLogged; } set { isLogged = value; } } public static bool Authenticate(string username, string password) { if (username == superAdminUsername &amp;&amp; password == superAdminPassword) { isLogged = true; return true; } return false; } </code></pre>
2
train a language model using Google Ngrams
<p>I want to find a conditional probability of a word given its previous set of words. I plan to use <code>Google N-grams</code> for the same. However, being such a huge resource as it is, I don't think it is computationally possible to do on my PC. ( To process all N-grams, to train a language model). </p> <p>So is there any way I can train a language model using Google Ngrams ? (Even <code>python NLTK</code> library does not support <code>ngram</code> language model anymore) Note - I know that a language model can be trained using ngrams, but given the vast size of Google N grams, how can a language model be trained using specifically Google ngrams?</p>
2
Sending on behalf of users with Amazon SES
<p>Sometimes it's necessary to send an email with the reply-to address of another user. For example, if a LinkedIn user sends a connection of theirs a LinkedIn message, it makes sense to send that email from the user that sent the message, so that clicking 'reply' actually replies to the person who sent the message. </p> <p>Is there a way to do this with Amazon SES? </p>
2
Error 501 when registering for push notifications with Firebase
<p>I migrated an existing iOS app that was using GCM to Firebase and implemented all methods exactly like the sample code. However, I keep getting an error whenever the app tries to get an instance id. The logged messages are:</p> <pre><code>2016-07-05 16:41:49.298: &lt;FIRInstanceID/WARNING&gt; Failed to fetch default token Error Domain=com.firebase.iid Code=501 "The operation couldn’t be completed. (com.firebase.iid error 501.)" 2016-07-05 16:42:01.676: &lt;FIRInstanceID/WARNING&gt; Failed to fetch default token Error Domain=com.firebase.iid Code=501 "The operation couldn’t be completed. (com.firebase.iid error 501.)" 2016-07-05 16:42:26.735: &lt;FIRInstanceID/WARNING&gt; Failed to fetch default token Error Domain=com.firebase.iid Code=501 "The operation couldn’t be completed. (com.firebase.iid error 501.)" 2016-07-05 16:43:05.580: &lt;FIRInstanceID/WARNING&gt; Failed to fetch default token Error Domain=com.firebase.iid Code=501 "The operation couldn’t be completed. (com.firebase.iid error 501.)" 2016-07-05 16:44:03.260: &lt;FIRInstanceID/WARNING&gt; Failed to fetch default token Error Domain=com.firebase.iid Code=501 "The operation couldn’t be completed. (com.firebase.iid error 501.)" 2016-07-05 16:44:03.261: &lt;FIRInstanceID/WARNING&gt; Failed to retrieve the default GCM token after 5 retries </code></pre> <p>Does anyone know why this happens? I contacted Firebase support and they couldn't help. </p> <p>Knowing that this is an app that was working fine before switching to Firebase, I know that push configurations on the app side are working. And considering that all the configuration on the Firebase Console was imported from my previous Google Project, I know that my certificates are all working as well (they are the same certificates).</p> <p>In an attempt to check whether my app code was the problem, I ran the sample app (<a href="https://github.com/firebase/quickstart-ios/tree/master/messaging/FCMSwift" rel="nofollow">https://github.com/firebase/quickstart-ios/tree/master/messaging/FCMSwift</a>), changing the Bundle Identifier and using my project's GoogleService-info.plist file and the result is the same 501 error, which leaves me no doubt that the problem is not with the app code.</p> <p>Does anyone have any clue how to solve this?</p>
2
Timer fired twice when running Windows service
<p>When the service is running the program runs twice. The average running time is 10 minutes. </p> <pre><code>private void InitializeTimer() { var confcontr = new ConfigurationController(); var config = confcontr.ReadConfiguration(); try { if (serviceTimer != null) { serviceTimer.AutoReset = true; Articles art = new Articles(config); //Conexion a a los articulos de BD para obtener parametros de iniciación serviceTimer.Interval = Convert.ToDouble(60*1000)* art.Parameter(); //Se especifica cada que tanto tiempo se ejecuta el servicio serviceTimer.Enabled = true; serviceTimer.Elapsed += serviceTimer_Elapsed; } } catch (Exception ex) { Log.Instance.WriteToLog(ex.Message + ex.StackTrace + "initializetimer"); } } </code></pre> <p>This is the method I'm calling </p> <pre><code>protected void serviceTimer_Elapsed(object sender, ElapsedEventArgs e) { var artcont = new ArticulosController(); artcont.EjecutarArticulo(); } </code></pre>
2
Re-render child component when back button is clicked
<p>Im wondering if there is any straightforward way to get a single child component to rerender when the back button is clicked. For example:</p> <pre><code>componentWillReceiveProps: function() { forceupdate &gt; child-one } &lt;parent&gt; &lt;child-one /&gt; &lt;child-two /&gt; &lt;/parent&gt; </code></pre> <p><code>componentWillReceiveProps</code> is hit whenever the back button is clicked.</p> <p>Any ideas? I don't want to re-render the entire parent component.</p>
2
Issue with passing string from Python to C shared lib using ctypes
<p>I'm having difficulty passing string from Python to C by ctypes:</p> <p>My C code(compiled into a hello.so)</p> <pre><code>... typedef struct test{ unsigned int a; unsigned char* b; } my_struct; int hello(my_struct *in) { FILE *fp; ... fprintf(fp, "%d\t%s\n", in-&gt;a, in-&gt;b); fclose(fp); return 0; } </code></pre> <p>My Python code:</p> <pre><code>... from ctypes import * ... class TEST_STRUCT(Structure): _fields_ = [("a", c_int), ("b", c_char_p)] ... hello_lib = ctypes.cdll.LoadLibrary("hello.so") hello = hello_lib.hello hello.argtypes = [POINTER(TEST_STRUCT)] name = create_string_buffer(b"test") hello_args = TEST_STRUCT(1, name) hello(ctypes.byref(hello_args)) ... </code></pre> <p>I get the error: hello_args = TEST_STRUCT(1, name) TypeError: expected string, c_char_Array_5 found</p> <p>I tried to change c_char_p to c_wchar_p or c_char*5 or c_wchar*5 etc. Sometimes it can run without error, the first int parameter of the struct can be printed correctly, but not the second string pointer, the best I can get is just the first character 't' instead of the whole word "test". </p> <p>BTW, my python3 version is 3.3.0</p>
2
drawRoundRect differents radius for each corner
<p>I would like to draw a square with differents corner radius, for example the top with a "25px" radius and the bottom not rounded.</p> <p>My current <code>code</code> (all the corner have the same radius)</p> <pre><code>c.drawRoundRect( tmpDrawHalf, // rect cornersRadius, // rx cornersRadius, // ry paint // Paint ); </code></pre> <p>How to achieve that ?</p> <p>EDIT: My goal: <a href="http://i.stack.imgur.com/CCu2f.png" rel="nofollow">Image</a></p>
2
Truncating float to the two first non-zero decimal digits
<p>I want to truncate floating point numbers in Java up to the two first non-zero decimal digits. For example, <code>0.000134</code> to <code>0.00013</code>, or <code>11.00401</code> to <code>11.0040</code>.</p> <p>The only solution I can think of is to strip the integral part, and multiply by 10 until I get a number bigger or equal to 10. Then truncate the original float up to <code>number of multiplications</code> decimal digits.</p> <p>But I might have to do this operation often, so I'm looking for a faster solution.</p> <p>My test code:</p> <pre><code>public static String truncateTo2NonZero(double f) { int integral = (int)f; double decimal = f - integral; int digits = 0; while (decimal &lt; 10) { decimal *= 10; digits++; } double ret = (int)decimal / Math.pow(10, digits); ret += integral; return Double.toString(ret); } public static void main(String args[]) { final int TESTS = 1000000; double[] floats = new double[TESTS]; Random random = new Random(); for (int i = 0; i &lt; TESTS; ++i) { int zeros = random.nextInt(6) + 3; // divide by 10^zeros double digits = random.nextInt(100) + 100; // 3 last digits floats[i] = digits / Math.pow(10,zeros) + random.nextInt(20) + 1; } long startTime = System.nanoTime(); for (int i = 0; i &lt; TESTS; ++i) truncateTo2NonZero(floats[i]); long endTime = System.nanoTime(); long duration = endTime - startTime; System.out.println(duration / 1000000); // in milliseconds } </code></pre> <p>I'm using Windows 7 Home Premium 64-bit. Output of <code>java -version</code>:</p> <pre><code>java version "1.8.0_20" Java(TM) SE Runtime Environment (build 1.8.0_20-b26) Java HotSpot(TM) 64-Bit Server VM (build 25.20-b23, mixed mode) </code></pre>
2
How to subscribe to multiple BluetoothLE Characteristics with Android
<p>I am developing an Android app which should subscribe to multiple BLE characteristics.</p> <p>But whatever I do, I receive only the updated values from one characteristic.</p> <p>Here is the code:</p> <pre><code>BluetoothGattCharacteristic characteristicVel = gatt.getService(BleDefinedUUIDs.Service.KOMMMODUL_SERVICE).getCharacteristic(BleDefinedUUIDs.Characteristic.VELOCITY); gatt.setCharacteristicNotification(characteristicVel, true); BluetoothGattDescriptor descriptorVel = characteristicVel.getDescriptor( BleDefinedUUIDs.Descriptor.CHAR_CLIENT_CONFIG); descriptorVel.setValue(BleDefinedUUIDs.Descriptor.ENABLE_NOTIFICATION_VALUE); gatt.writeDescriptor(descriptorVel); BluetoothGattCharacteristic characteristicAcc = gatt.getService(BleDefinedUUIDs.Service.KOMMMODUL_SERVICE).getCharacteristic(BleDefinedUUIDs.Characteristic.ACCELERATION); gatt.setCharacteristicNotification(characteristicAcc, true); BluetoothGattDescriptor descriptorAcc = characteristicAcc.getDescriptor( BleDefinedUUIDs.Descriptor.CHAR_CLIENT_CONFIG); descriptorAcc.setValue(BleDefinedUUIDs.Descriptor.ENABLE_NOTIFICATION_VALUE); gatt.writeDescriptor(descriptorAcc); </code></pre> <p>Whatever I do I get only the velocity data. If I change the order of the two blocks I get acceleration only but no more velocity data.</p> <p>What have I to do in order to subscribe to many characteristics at once?</p> <p>Thanks in advance</p> <p>Reto</p>
2
React native background image warning: Invalid props.style key `resizeMode` supplied to `View`
<p>Gathering guidance from <a href="https://stackoverflow.com/questions/29322973/whats-the-best-way-to-add-a-full-screen-background-image-in-react-native">this post</a> about how to create a background image in RN I learned that I need to have an Image containing other elements:</p> <pre><code> &lt;Image style=... source=...&gt; &lt;Text&gt;Hello&lt;/Text&gt; &lt;/Image&gt; </code></pre> <p>However, I think that when an Image has inner elements RN converts it to a view. I came to this conclusion because I am getting this warning:</p> <p><a href="https://i.stack.imgur.com/0ji2g.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0ji2g.png" alt="warning about view properties"></a></p> <p>This is peculiar as the resizeMode was supplied to an Image and not to a View. The style of the containing image as described in the warning:</p> <pre><code>{ width: null, height: null, overflow: "hidden", flex: 1, flexDirection: "column", justifyContent: "space-between", alignItems: "stretch", resizeMode: "cover" } </code></pre> <p>Should I ignore this warning or is there a proper way to create these kind of structures:</p> <p><a href="https://i.stack.imgur.com/Glq0Q.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Glq0Q.png" alt="image background structure"></a></p>
2
Java Oracle connection - Connection has already been closed
<p>I simplify the code as below:</p> <pre><code>Connection conn = dataSource.getConnection(); UserTransaction ut = util.getTransaction(); // ut.begin(); for (xxx) { // heavy for-loop, a lot of records ut.begin(); PreparedStatement pstmt = conn.prepareStatement(sql); // very fast sql update pstmt.executeUpdate(); pstmt.close(); ut.commit(); } //ut.commit(); </code></pre> <p>As the code above, the <code>for-loop</code> will be running very long, around 1-2 hour.</p> <p>Last time, when I put the <code>begin</code> and <code>commit</code> outside of <code>for-loop</code>, I encounter an error in the end of loop:</p> <pre><code>java.sql.SQLRecoverableException: IO Error: Connection timed out at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:1065) at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1329) </code></pre> <p>Then I realize, system not able to commit because in this case, <code>UserTransaction</code> maybe already timeout. (error throw at the <code>ut.commit()</code>)</p> <p>So I move the <code>begin</code> and <code>commit</code> into the <code>for-loop</code> to avoid the issue, but I got another error in somewhere around 1 hour and half:</p> <pre><code>java.sql.SQLException: Connection has already been closed. at weblogic.jdbc.wrapper.PoolConnection.checkConnection(PoolConnection.java:62) at weblogic.jdbc.wrapper.Connection.preInvocationHandler(Connection.java:100) at weblogic.jdbc.wrapper.Connection.prepareStatement(Connection.java:553) </code></pre> <p>My code is single threaded, so I am very sure, there is no other thread that close the <code>conn</code> connection. (this time the error throw at <code>conn.prepareStatement(sql)</code>)</p> <p>And due to the <code>for-loop</code>, the connection is not idle, because it keep doing <code>update</code> and <code>commit</code>. How can a connection auto-closed (due to whatever reason? timeout?)?</p> <p>So what happen to the connection? I searched but can't find any timeout settings like connection's pool borrow timeout or blah blah blah. </p> <p>Anyone has idea?</p>
2
setjmp/longjmp between threads to handle timeout
<p>I'm porting a software from an embedded computer to a Linux machine. (Ubuntu 14.04 or Raspbian (raspberry pi))</p> <p>The original program was using setjmp/longjmp to handle timeout and CTRL+C event. It was running on a Microcontroller with a single main (one thread).</p> <p>I'm trying to have a similar behaviour while using threads (pthreads).</p> <p>The idea is that I want either a timeout or a CTRL+C to restart an infinite loop.</p> <p>The original code was doing something like the code below. I don't mind to drop the setjmp/longjmp by something else. (ex: try/catch or signal or pthread_kill, conditional variable, etc..)</p> <p>Any idea how to implement similar behavior with C/C++ ?</p> <p>Here is the code which seems to partially work and is probably not recommended/broken:</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #include &lt;signal.h&gt; #include &lt;string.h&gt; #include &lt;unistd.h&gt; #include &lt;pthread.h&gt; #include &lt;setjmp.h&gt; // Define #define TICK_NS_TIME (10000000) // 0.01 sec = 10 ms (100 times per second) #define NS_PER_SEC (1000000000) // Nano sec per second. #define TICK_PER_SEC (NS_PER_SEC/TICK_NS_TIME) // Number of tick per second (Ex:100) #define TIMEOUT_COUNT (30*TICK_PER_SEC) // 30 seconds timeout (with 100 tick per second) // Env set/long jmp #define ENV_SZ (2) #define ENV_TIMEOUT (0) #define ENV_CTRLC (1) static jmp_buf env[ENV_SZ]; // Variables int timeout_val; // sig handler. void signal_handler(int signo) { pthread_t self = pthread_self(); printf("Thread %lu in signal handler\n", (long)self); if (signo == SIGINT) { longjmp(env[ENV_CTRLC], 1); // Q?: Is it in the same thread ? (Never, Always, Sometimes?) } else { printf("Other signal received..quitting."); // Ex: kill -9 pid exit(0); } } // thread timer function void* timer_function(void* in_param) { // Loop approx 100x per second. for (;;) { nanosleep((const struct timespec[]){{0, TICK_NS_TIME }}, NULL); // Sleep 10 ms seconds. if (timeout_val) { if (!--timeout_val) { longjmp(env[ENV_TIMEOUT], 1); // longjmp when timer reaches 0. (Q?: Is this valid with multithread?) } } } } // main int main(int argc, char **argv) { int i; int val; struct sigaction actions; pthread_t thread; setvbuf (stdout, NULL, _IONBF, 0); // Make sure stdout is not buffered (ex:printf, etc.) printf("[Program started]\r\n"); memset(&amp;actions, 0, sizeof(actions)); sigemptyset(&amp;actions.sa_mask); actions.sa_flags = 0; actions.sa_handler = signal_handler; val = sigaction(SIGINT, &amp;actions, NULL); pthread_create(&amp;thread, NULL, timer_function, NULL); // timer thread for example printf("[Timer thread started]\r\n"); // setting env. val = setjmp(env[ENV_TIMEOUT]); if (val!=0){ printf("[JMP TIMEOUT]\r\n"); } val = setjmp(env[ENV_CTRLC]); if (val!=0){ printf("[JMP CTRLC]\r\n"); } // main loop timeout_val = TIMEOUT_COUNT; i = 0; for (;;) { i++; if (i &gt; 10){ i = 0; printf("[%d]", timeout_val/TICK_PER_SEC); } // Number of seconds before time out. sleep(1); printf("."); } printf("Main completed\n"); return 0; } //Compile: g++ -pthread main.cpp -o main </code></pre> <p>Suggestion for alternative implementation would be great since I'm new to programming with threads !</p>
2
Is there a git command to show new upstream commits after fetch?
<p>Is there some shortcut to specify the interval of fetched, new commits from remote tracking branch? Instead of typing this long command that is also branch specific:</p> <pre><code>git log branchName..origin/branchName </code></pre> <p>I am looking for some git interval hack, that will represent interval of branchName..origin/branchName, something like (not working, equivalent to git log ..origin/HEAD)</p> <pre><code>git log ..origin </code></pre>
2
How to port QNetworkAccessManager to WebEngine?
<p>I know that Qt WebEngine does not interact with QNetworkAccessManager. But how do you port this code from 5.5 to 5.7 in order for it to work?</p> <pre><code>QNetworkAccessManager *p = getView()-&gt;page()-&gt;networkAccessManager(); </code></pre> <p>networkAccessManager is highlited and error says "class QWebEnginePage has no member networkAccessManager"</p>
2
How to compare files using Byte Array and Hash
<h2>Background</h2> <p>I am converting media files to a new format and need a way of knowing if I've previously in current runtime, converted a file. </p> <h2>My solution</h2> <p>To hash each file and store the hash in an array. Each time I go to convert a file I hash it and check the hash against the hashes stored in the array.</p> <h2>Problem</h2> <p>My logic doesn't seem able to detect when I've already seen a file and I end up converting the same file multiple times.</p> <h2>Code</h2> <pre><code>//Byte array of already processed files private static readonly List&lt;byte[]&gt; Bytelist = new List&lt;byte[]&gt;(); public static bool DoCheck(string file) { FileInfo info = new FileInfo(file); while (FrmMain.IsFileLocked(info)) //Make sure file is finished being copied/moved { Thread.Sleep(500); } //Get byte sig of file and if seen before dont process byte[] myFileData = File.ReadAllBytes(file); byte[] myHash = MD5.Create().ComputeHash(myFileData); if (Bytelist.Count != 0) { foreach (var item in Bytelist) { //If seen before ignore if (myHash == item) { return true; } } } Bytelist.Add(myHash); return false; } </code></pre> <h2>Question</h2> <p>Is there more efficient way of trying to acheive my end goal? What am I doing wrong?</p>
2
JobScheduler setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY) not working
<p>The following code never runs. The job is scheduled successfully however it is never actually executed. I've even set an overriding deadline of 1m10s. The device is connected to WiFi at all times and even after 5 hours of wait, I never see it launched. What am I doing wrong?</p> <pre><code> int REFRESH_JOB_ID = 13; jobScheduler.cancel(REFRESH_JOB_ID); // Requires WiFi / Edge / 3G JobInfo jobInfo = new JobInfo.Builder(REFRESH_JOB_ID, componentName). setMinimumLatency(1 * 60 * 1000). setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY). setRequiresCharging(false). setRequiresDeviceIdle(false). setPersisted(true). setOverrideDeadline((1 * 60 * 1000) + (10*1000)). build(); int errorCode = 0; if ((errorCode = jobScheduler.schedule(jobInfo)) &gt; 0) { Log.i("Auto Scheduler", "... job has been scheduled: " + errorCode); } else { Log.e("Auto Scheduler", "... job FAILED to schedule: " + errorCode); } </code></pre>
2
how to get Json Object in jax-rs Restful web services
<p>I have tried to get the <code>json</code> object from android client in my <code>Ejb</code> Based Web application which used <code>Restful</code> api with <code>jax-rs</code>. But I'm unavailable to get the <code>json</code> object. It throw 404 error even I have match all the keyname with my entity class variable</p> <p>My <code>pojo</code> class look like this:</p> <pre><code>@Entity @Table(name = "events") @NamedQueries({ @NamedQuery(name = Event.FIND_ALL,query="Select e from Event e") }) public class Event implements Serializable{ public static final String PREFIX="np.com.drose.data.modules.employee.domain.event."; public static final String FIND_ALL=PREFIX+"FIND_ALL"; @Id @GeneratedValue private int eventId; @Future @Temporal(TemporalType.DATE) private Date dateofEvent; private String content; private String header; private String place; private String specification; public int getEventId() { return eventId; } public void setEventId(int eventId) { this.eventId = eventId; } public Date getDateofEvent() { return dateofEvent; } public void setDateofEvent(Date dateofEvent) { this.dateofEvent = dateofEvent; } public String getContent() { return content; } public void setContent(String content) { this.content = content; } public String getHeader() { return header; } public void setHeader(String header) { this.header = header; } public String getSpecification() { return specification; } public void setSpecification(String specification) { this.specification = specification; } public String getPlace() { return place; } public void setPlace(String place) { this.place = place; } } </code></pre> <p>and my Resources class look like this:</p> <pre><code> @Path("secured") @Stateless public class EventAddResurces { @Inject EventServices eventServices; @POST @Path("/event/add") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.TEXT_PLAIN) public Response getResponse(Event event){ this.eventServices.addEvent(event); return Response.ok().status(200).entity("Successfully added").build(); } } </code></pre>
2
POST request returns 415 error
<p>I'm trying to call a POST request (using Jersey APi for REST) from an HTML form using AngularJS v 1.5.8. <br> I have an HTML form with a submit button that calls a REST serivce:</p> <pre><code>&lt;body ng-app="myApp" ng-controller="loginController"&gt; ...... &lt;form name="myForm" nonvalidate ng-submit="login()"&gt; ...... &lt;div class="col-md-4 col-md-offset-4 col-sm-4 col-sm-offset-3 col-xs-6 col-xs-offset-3"&gt; &lt;button type="submit" class="btn btn-default" ng-submit="login()"&gt;Submit&lt;/button&gt; &lt;/div&gt; &lt;/form&gt; </code></pre> <p>This is my loginController script:</p> <pre><code>var app = angular.module ("myApp", []); app.controller("loginController", function($scope, $http){ $scope.username = ""; $scope.password = ""; $scope.login = function() { var transform = function(data) { return $.param(data); } $http( { url : 'http://localhost:8080/RestServices/services/user/add', method : 'POST', headers : { 'Content-Type' : 'application/x-www-form-urlencoded; charset=UTF-8' }, transformRequest : function(data) { return $.param(data); }, data: { name: $scope.username, password: $scope.password } }).success(function(response, status) { $scope.data = response; //Assign data received to $scope.data } ) } } ) </code></pre> <p>And here is my simple REST post service:</p> <pre><code>@Path("user") public class UserResource { private TreeMap&lt;Integer, User&gt; userMap = new TreeMap&lt;Integer, User&gt;(); @POST @Path("add") @Consumes({MediaType.APPLICATION_JSON}) public Response addUser(User user) { int id = userMap.size(); user.setId(id); userMap.put(id, user); ObjectMapper mapper = new ObjectMapper(); String jsonString = ""; try { jsonString = mapper.writeValueAsString(user); } catch (JsonProcessingException e) { // TODO Auto-generated catch block e.printStackTrace(); jsonString = null; } return Response.ok().entity(jsonString).build(); } } </code></pre> <p>The POST request is called but returns a 415 error: <em>the server refused this request because the request entity is in a format not supported by the requested resource for the requested method.</em></p>
2
Android Studio fails to recognise &lt; and &gt; tags
<p>Android Studio wont recognize html tags, they're highlighted in red, it says " cannot resolve symbol 'gt' " and the project wont build. Does anyone know why exactly and how I could fix this? Any input whatsoever would be greatly appreciated. </p> <p>Here is the error : </p> <pre><code>Configuration on demand is an incubating feature. Incremental java compilation is an incubating feature. :app:preBuild UP-TO-DATE :app:preDebugBuild UP-TO-DATE :app:checkDebugManifest :app:preReleaseBuild UP-TO-DATE :app:prepareComAndroidSupportAnimatedVectorDrawable2400Library UP-TO-DATE :app:prepareComAndroidSupportAppcompatV72400Library UP-TO-DATE :app:prepareComAndroidSupportSupportV42400Library UP-TO-DATE :app:prepareComAndroidSupportSupportVectorDrawable2400Library UP-TO-DATE :app:prepareDebugDependencies :app:compileDebugAidl UP-TO-DATE :app:compileDebugRenderscript UP-TO-DATE :app:generateDebugBuildConfig UP-TO-DATE :app:mergeDebugShaders UP-TO-DATE :app:compileDebugShaders UP-TO-DATE :app:generateDebugAssets UP-TO-DATE :app:mergeDebugAssets UP-TO-DATE :app:generateDebugResValues UP-TO-DATE :app:generateDebugResources UP-TO-DATE :app:mergeDebugResources UP-TO-DATE :app:processDebugManifest :app:processDebugResources UP-TO-DATE :app:generateDebugSources UP-TO-DATE :app:incrementalDebugJavaCompilationSafeguard :app:compileDebugJavaWithJavac :app:compileDebugJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.). /home/zerodavila/AndroidStudioProjects/ZLayer4 (another copy)/app/src/main/java/com/hivemind/zerodavila/zlayer4/MusicService.java:166: error: ')' expected if(songPosn&amp; lt; 0) songPosn=songs.size()-1; ^ /home/zerodavila/AndroidStudioProjects/ZLayer4 (another copy)/app/src/main/java/com/hivemind/zerodavila/zlayer4/MusicService.java:166: error: not a statement if(songPosn&amp; lt; 0) songPosn=songs.size()-1; ^ /home/zerodavila/AndroidStudioProjects/ZLayer4 (another copy)/app/src/main/java/com/hivemind/zerodavila/zlayer4/MusicService.java:166: error: ';' expected if(songPosn&amp; lt; 0) songPosn=songs.size()-1; ^ /home/zerodavila/AndroidStudioProjects/ZLayer4 (another copy)/app/src/main/java/com/hivemind/zerodavila/zlayer4/MusicService.java:173: error: ')' expected if(songPosn&amp; gt; =songs.size()) songPosn=0; ^ /home/zerodavila/AndroidStudioProjects/ZLayer4 (another copy)/app/src/main/java/com/hivemind/zerodavila/zlayer4/MusicService.java:173: error: illegal start of expression if(songPosn&amp; gt; =songs.size()) songPosn=0; ^ /home/zerodavila/AndroidStudioProjects/ZLayer4 (another copy)/app/src/main/java/com/hivemind/zerodavila/zlayer4/MusicService.java:173: error: ';' expected if(songPosn&amp; gt; =songs.size()) songPosn=0; ^ 6 errors :app:compileDebugJavaWithJavac FAILED FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':app:compileDebugJavaWithJavac'. &gt; Compilation failed; see the compiler error output for details. * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. BUILD FAILED Configuration on demand is an incubating feature. Incremental java compilation is an incubating feature. :app:preBuild UP-TO-DATE :app:preDebugBuild UP-TO-DATE :app:checkDebugManifest :app:preReleaseBuild UP-TO-DATE :app:prepareComAndroidSupportAnimatedVectorDrawable2400Library UP-TO-DATE :app:prepareComAndroidSupportAppcompatV72400Library UP-TO-DATE :app:prepareComAndroidSupportSupportV42400Library UP-TO-DATE :app:prepareComAndroidSupportSupportVectorDrawable2400Library UP-TO-DATE :app:prepareDebugDependencies :app:compileDebugAidl UP-TO-DATE :app:compileDebugRenderscript UP-TO-DATE :app:generateDebugBuildConfig UP-TO-DATE :app:mergeDebugShaders UP-TO-DATE :app:compileDebugShaders UP-TO-DATE :app:generateDebugAssets UP-TO-DATE :app:mergeDebugAssets UP-TO-DATE :app:generateDebugResValues UP-TO-DATE :app:generateDebugResources UP-TO-DATE :app:mergeDebugResources UP-TO-DATE :app:processDebugManifest :app:processDebugResources UP-TO-DATE :app:generateDebugSources UP-TO-DATE :app:incrementalDebugJavaCompilationSafeguard :app:compileDebugJavaWithJavac :app:compileDebugJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.). /home/zerodavila/AndroidStudioProjects/ZLayer4 (another copy)/app/src/main/java/com/hivemind/zerodavila/zlayer4/MusicService.java:166: error: ')' expected if(songPosn&amp; lt; 0) songPosn=songs.size()-1; ^ /home/zerodavila/AndroidStudioProjects/ZLayer4 (another copy)/app/src/main/java/com/hivemind/zerodavila/zlayer4/MusicService.java:166: error: not a statement if(songPosn&amp; lt; 0) songPosn=songs.size()-1; ^ /home/zerodavila/AndroidStudioProjects/ZLayer4 (another copy)/app/src/main/java/com/hivemind/zerodavila/zlayer4/MusicService.java:166: error: ';' expected if(songPosn&amp; lt; 0) songPosn=songs.size()-1; ^ /home/zerodavila/AndroidStudioProjects/ZLayer4 (another copy)/app/src/main/java/com/hivemind/zerodavila/zlayer4/MusicService.java:173: error: ')' expected if(songPosn&amp; gt; =songs.size()) songPosn=0; ^ /home/zerodavila/AndroidStudioProjects/ZLayer4 (another copy)/app/src/main/java/com/hivemind/zerodavila/zlayer4/MusicService.java:173: error: illegal start of expression if(songPosn&amp; gt; =songs.size()) songPosn=0; ^ /home/zerodavila/AndroidStudioProjects/ZLayer4 (another copy)/app/src/main/java/com/hivemind/zerodavila/zlayer4/MusicService.java:173: error: ';' expected if(songPosn&amp; gt; =songs.size()) songPosn=0; ^ 6 errors :app:compileDebugJavaWithJavac FAILED FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':app:compileDebugJavaWithJavac'. &gt; Compilation failed; see the compiler error output for details. * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. BUILD FAILED Total time: 1 mins 19.833 secs Total time: 1 mins 19.833 secs </code></pre>
2
Regex in Apache Derby
<p>Is it possible to extract a string from a varchar field in Apache Derby?</p> <p>I'd like to use a regular expression. Something like:</p> <pre><code>select regex('Joe Bloggs', '(\w+)\s(\w+)', 2) as surname from SYSIBM.SYSDUMMY1 </code></pre>
2
Calculating Average from a list of students taken from a .txt file
<p>I have a separated .txt file in which there is a list of "students" with their own mark on the side that goes from 0 to 10, here is an example on how the .txt looks like:</p> <blockquote> <p>Mark 2<br> Elen 3<br> Luke 7<br> Elen 9<br> Jhon 5<br> Mark 4<br> Elen 10<br> Luke 1<br> Jhon 1<br> Jhon 7<br> Elen 5<br> Mark 3<br> Mark 7 </p> </blockquote> <p>What I want to do is calculating the Average of each student (expressed in <code>double</code>) so that the output would look like this:</p> <pre><code>Mark: 4.0 Elen: 6.75 Luke: 4.0 Jhon: 4.33 </code></pre> <p>Here is what I've come up with, for now I've only managed to use <code>Properties</code> to list the student names without repetition, but the number shown on the side of each one of them is obviously the last one the program finds.<br> I've included it on a button actionlistener as I'm implementing a GUI, by pressing the button the output shown above is <code>append</code> in a <code>TextArea</code>: </p> <pre><code> b1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent d) { try { File file = new File("RegistroVoti.txt"); FileInputStream fileInput = new FileInputStream(file); Properties properties = new Properties(); properties.load(fileInput); fileInput.close(); Enumeration enuKeys = properties.keys(); while (enuKeys.hasMoreElements()) { String key = (String) enuKeys.nextElement(); String value = properties.getProperty(key); l1.append(key + ": " + value + "\n"); } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } }); </code></pre> <p>I was thinking to use <code>Collectors</code> to calculate the average, but I actually don't know how to implement it...</p> <p>Any help is appreciated!</p> <p>Thanks in advance!</p>
2
iOS Metal – reading old values while writing into texture
<p>I have a kernel function (compute shader) that reads nearby pixels of a pixel from a texture and based on the old nearby-pixel values updates the value of the current pixel (<em>it's not a simple convolution</em>).</p> <p>I've tried creating a copy of the texture using <code>BlitCommandEncoder</code> and feeding the kernel function with 2 textures - one read-only and another write-only. Unfortunately, this approach is GPU-wise time consuming.</p> <p>What is the most efficient (GPU- and memory-wise) way of reading old values from a texture while updating its content?</p>
2
Late Static Binding and Instance Methods in TypeScript
<p>Am very curious how/why the following trickery is needed in TypeScript. Was playing around with basic <code>class</code> and <code>static</code> constructs, then inheritance, and finally referencing <code>static</code> properties from <code>instance</code> methods. I might not ever implement anything this way... but I did get quite confused <em>why</em> the following works:</p> <pre><code>class Foo { msg: string; static name: string = 'Foo'; static sayHi(): string { return `hello from ${this.name}`; } constructor() { // this.msg = `I am ${Foo.name}`; // 2x `I am Foo` // this.msg = `I am ${this.name}`; // error TS2339: Property 'name' does not exist on type 'Foo'. // this.msg = `I am ${this.constructor.name}`; // error TS2339: Property 'name' does not exist on type 'Function'. const cls = &lt;typeof Foo&gt;this.constructor; this.msg = `I am ${cls.name}`; } } class Bar extends Foo { static name: string = 'Bar'; } console.log(Foo.sayHi()); // hello from Foo console.log(Bar.sayHi()); // hello from Bar console.log((new Foo()).msg); // I am Foo console.log((new Bar()).msg); // I am Bar </code></pre> <p>(i'm on <code>tsc 1.8.10</code>, the <strong>UPDATE</strong> in <a href="https://stackoverflow.com/a/29244254/1345249">this answer</a> got it working)</p> <p>If you jump to @basarat's response, WHY does the type assertion magically make everything work?</p> <p>Compared to similar python:</p> <pre><code>class Foo(object): name = 'Foo' @classmethod def sayHi(cls): return 'hello from {}'.format(cls.name) def __init__(self): self.msg = 'I am {}'.format(self.name); class Bar(Foo): name = 'Bar' print(Foo.sayHi()) # hello from Foo print(Bar.sayHi()) # hello from Bar print(Foo().msg) # I am Foo print(Bar().msg) # I am Bar </code></pre>
2
Change a Style based on Visual State
<p><em>"Blend makes it simple to setup Visual States based on say <code>minWindowWidth</code>. But it would be very nice to have state-based Styles defined for <code>TextBlock</code> elements, say with <code>tag="header"</code>, <code>tag="body"</code>, and have the Setter change the Style automatically."</em></p> <p>Maybe I wasn't explicit enough in my initial question, let me rephrase this.</p> <p>I am resizing my application window from say Landscape to Portrait. My VisualStateManager has setters which adjust the page properties based on the new minimum width.</p> <p>I have multiple TextBlocks (header,body, etc) and other controls with .Text (ToggleSwitch), that I want to automatically adjust FontSize based on the new width.</p> <p>Aside from manually setting every single control by name in all the states, is there a way to have the VisualStateManager do it automatically for each 'type' of Text(body/header/etc)? My work around at the moment is to DataBind a Style for every .Text control and have the ViewModel do all the scaling. That works, but this is really something Blend is made for, right? So I must be missing the obvious way everyone is using.</p> <p>Thanks for all the good comments so far.</p> <pre><code> &lt;VisualStateManager.VisualStateGroups&gt; &lt;VisualStateGroup x:Name="VisualStateGroup"&gt; &lt;VisualState x:Name="PhonePortrait"&gt; &lt;VisualState.StateTriggers&gt; &lt;AdaptiveTrigger MinWindowWidth="{StaticResource NarrowMinWidth}"/&gt; &lt;/VisualState.StateTriggers&gt; &lt;VisualState.Setters&gt; &lt;Setter Target="SwitchStackPanel.(StackPanel.Orientation)" Value="Vertical"/&gt; &lt;!-- Setter to change all Body textblocks to FontSize=8--&gt; &lt;!-- Setter to change all Header textblocks to FontSize=10--&gt; &lt;!-- Setter to change all ToggleSwitch.Text to FontSize=8--&gt; &lt;!-- etc..--&gt; </code></pre>
2
Why does PhpStorm report an "Argument type does not match" error?
<p>I am working on a <strong>PHP 7</strong> project with <strong>PhpStorm 10.0.2</strong>.</p> <p>Whenever I declare a PHPDoc <code>@param</code> for an function parameter that has type hinting for a scalar type (<code>string</code>, <code>int</code>, ...) I get this warning:</p> <blockquote> <p>Argument type does not match</p> </blockquote> <p>Here is some sample code that PhpStorm complains about:</p> <pre><code>class HostConfig { /** * @var string */ private $hostname; /** * @var string */ private $domainname; /** * Creates a new instance of hte HostConfig model. * * @param string $hostname A host name (e.g. "dev", "int", "feature-xy") * @param string $domainname A domain name (e.g. "example.com") * * @throws \InvalidArgumentException If the given $hostname is empty * @throws \InvalidArgumentException If the given $domainname is empty */ public function __construct(string $hostname, string $domainname) { if (strlen(trim($hostname)) === 0) { throw new \InvalidArgumentException("The host name cannot be empty"); } if (strlen(trim($domainname)) === 0) { throw new \InvalidArgumentException("The domain name cannot be empty"); } $this-&gt;hostname = $hostname; $this-&gt;domainname = $domainname; } } </code></pre> <p>And a screenshot of PhpStorm displaying the questionable "Argument type does not match"-hint for in the PHPDoc for an constructor that has two strongly typed string parameters:</p> <p><a href="https://i.stack.imgur.com/8ly6g.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8ly6g.png" alt="Screenshot of PhpStorm displaying an &quot;Argument type does not match&quot; hint for a string function parameter that has type hinting"></a></p> <p>Does anybody know if I am doing something wrong or if this is just a bug in PhpStorm?</p>
2
Phonegap Unable to Install the apk file on android
<p>I have recently got the following error while installing PhoneGap build apk on phone or emulator</p> <pre><code> pkg: /data/local/tmp/android-debug.apk Failure [INSTALL_FAILED_UPDATE_INCOMPATIBLE] </code></pre> <p>Then I found the reason for it is due to signatures of the build app So then I uninstalled my android studio and Updated my Node js. Now I can install it on Emulator but not the phone Still I am getting the same error. </p> <p>I have already gone through the solution available on the Internet including <a href="https://stackoverflow.com/questions/11891848/install-failed-update-incompatible-when-i-try-to-install-compiled-apk-on-device">INSTALL_FAILED_UPDATE_INCOMPATIBLE when I try to install compiled .apk on device</a></p> <p>With help of available solutions, I can install in Emulator but not in my when phone and I don't have any previous versions of the app to uninstall the app</p> <p>Still, I have no clue how to solve this error.</p> <p>Please help to how to solve it.</p>
2
Android draw ImageView programmatically
<p>I am trying to draw an image into my canvas. In the constructor:</p> <pre><code>this.Icon = new ImageView(context); this.Icon.SetImageResource(Resource.Drawable.icon); this.Icon.LayoutParameters = new ViewGroup.LayoutParams(width, height); </code></pre> <p>And in the <code>OnDraw</code>:</p> <pre><code>protected override void OnDraw(Canvas canvas) { this.Icon.SetX(x); this.Icon.SetY(y); this.Icon.RequestLayout(); this.Icon.Draw(canvas); } </code></pre> <p>It is not appearing. Am I missing something?</p> <p>My class extends <code>View</code></p>
2
Get all React components inside of a React element
<p>Here is my code so far:</p> <pre><code>var allComponents = [] function getAllComponents (el) { if (!el) return if (!el.type) return allComponents.push(el.type) // Try to get all children components React.Children.forEach(el.props.children, getAllComponents) } </code></pre> <p>I am trying to find "every" component that has been created inside of a react element, however the above code will only get the direct <code>props.children</code>.</p> <p>This means that given this example React element:</p> <pre><code>function ComponentA (props) { return ( &lt;div&gt; &lt;h1&gt;Stuff&lt;/h1&gt; &lt;ComponentB/&gt; &lt;ComponentC/&gt; {props.children} &lt;/div&gt; ) } var el = ( &lt;ComponentA&gt; &lt;ComponentD/&gt; &lt;ComponentE/&gt; &lt;/ComponentA&gt; ) getAllComponents(el) //-&gt; [ComponentA, ComponentD, ComponentE] </code></pre> <p>The output will only have <code>ComponentA</code>, <code>ComponentD</code> and <code>ComponentE</code>, not <code>ComponentB</code> or <code>ComponentC</code> since they are not located in <code>props.children</code> but are instead a part of the component.</p> <p>Is there any way to also get <code>ComponentB</code> and <code>ComponentC</code> programatically (without doing something like refs since i'd prefer not to litter refs everywhere)?</p>
2
How can I develop on remote server with netbeans
<p>I am developing a java web application with netbeans. The application has to run on a "strong" server and cant run on my computer for testing.</p> <p>Today I developed and loaded the *.war file with the Tomcat Web Application Manager. This takes a long long time - 10 minutes. I assume that the time is needed to load all files (also libs) to the server each time.</p> <p>Is there a way to develop with netbeans remote on the server or upload only the edited files? </p> <p>Thank you! </p>
2
NavMeshAgent stuck (outside) the NavMesh
<p>For enemies, I set a random position on the nav mesh every x seconds, so that the enemies walk around randomly. Here my scripts:</p> <p>Random point (from the unity docs)</p> <pre><code>bool RandomPoint (Vector3 center, float range, out Vector3 result) { for (int i = 0; i &lt; 30; i++) { Vector3 randomPoint = center + Random.insideUnitSphere * range; NavMeshHit hit; if (NavMesh.SamplePosition (randomPoint, out hit, 1.0f, NavMesh.AllAreas)) { result = hit.position; return true; } } result = Vector3.zero; return false; } </code></pre> <p>My random movement script:</p> <pre><code>IEnumerator Walking () { if (!isFollowingPlayer &amp;&amp; isServer) { Debug.LogError ("-- Start Walking --"); agent.speed = 2; Vector3 randomDirection; bool blocked = RandomPoint (agent.transform.position, walkRadius, out randomDirection); NavMeshHit hit; blocked = NavMesh.Raycast (enemy.transform.position, randomDirection, out hit, NavMesh.AllAreas); if (!blocked) { geileMethodeZumZeichnen (agent); target = hit.position; agent.SetDestination (hit.position); geileMethodeZumZeichnen (agent); Debug.LogWarning ("Go to " + hit.position); } if (blocked) { Debug.LogWarning ("-- BLOCKED --"); yield return new WaitForEndOfFrame (); } else { Debug.LogWarning ("-- WAIT --"); yield return new WaitForSeconds (5f); } StartCoroutine ("Walking"); } } </code></pre> <p>The random walking generally works. However when a nav mesh agent is close to the border of the nav mesh, it appears that he "breaks out" and is then stuck to his position. He only "jitters around" outside the nav mesh. (red lines on the image : path)</p> <p><a href="https://i.stack.imgur.com/gJaUY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gJaUY.png" alt="NavMesh"></a></p> <p>Looks like they try to reach their position but can not enter the nav mesh again. I don't want them to leave in first place :)</p>
2
Reducing a list of futures
<p>I have long running function that returns a future as follows:</p> <pre><code>def longRunningFunction(signs: List[String], numOfWords: Int) : Future[List[(String, Int)]] = Future{ /* computation */ } </code></pre> <p>I need to reduce the output of the Future as follows:</p> <pre><code>val all = (6 to 24).map(i =&gt; longRunningFunction(signs, i)) .reduce(_ ::: _) </code></pre> <p>But this does not seem to work. Any thoughts?</p>
2
Chrome emulator not the same as iPhone - better emulator?
<p>Im building a mobile website and im not making it responsive. I am using media queries for each device. You may or may not think that is a good idea but I want to do it this way as the site is only 3 pages and very small and only accessible via mobiles.</p> <p>My problem is that I need a good emulator so that I can adjust for the phones I do not own. I only have an iPhone to test and Chrome is not matching up. Is there a better emulator out there, or am I doing something wrong?</p> <p><a href="http://i.stack.imgur.com/Pb5gG.jpg" rel="nofollow">Chrome version</a></p> <p><a href="http://i.stack.imgur.com/hejkw.png" rel="nofollow">Actual screenshot from iPhone</a></p> <p>Thanks.</p> <pre><code>&lt;meta name="viewport" content="width=device-width, maximum-scale=1.0, minimum-scale=1.0, initial-scale=1.0"/&gt; </code></pre>
2
How to open a context menu with right click on a ListViewItem
<p>The title pretty much says it all. Can someone explain to me how can I open a context menu by selecting and then right clicking on a <code>ListViewItem</code> of a <code>ListView</code>?</p> <p>I tried using the following code</p> <pre><code>private void listView1_MouseClick(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { if (listView1.FocusedItem.Bounds.Contains(e.Location) == true) { contextMenuStrip1.Show(Cursor.Position); } } } </code></pre> <p>But I don't know how to register this event handler with the <code>ListView</code>. Every time I try I get the error that the delegates parameters are wrong because I use <code>MouseEventArgs</code> instead of <code>EventArgs</code>.</p> <p>This is the wrong code I'm using to register the <code>EventHandler</code></p> <pre><code>this.listView1.MouseClick += new System.EventHandler(this.listView1_MouseClick); </code></pre>
2
ioerror errno 13 permission denied: 'C:\\pagefile.sys'
<p>Below is my code, what I am trying to achieve is walking through the OS generating a MD5 hash of every file the code is functional, however, I receive the error in the title "ioerror errno 13 permission denied: 'C:\pagefile.sys'" when I try to run the file from C:\ is there a way i can run this as an admin? Even when I run cmd as an admin that does not work, thank you in advance.</p> <pre><code>import os, hashlib current_dir = os.getcwd() for root,dirs,files in os.walk(current_dir): for f in files: current_file = os.path.join(root,f) H = hashlib.md5() with open(current_file) as FIN: H.update(FIN.read()) with open("gethashes.txt", "a") as myfile: myfile.write(current_file),myfile.write(", "),myfile.write(H.hexdigest()),myfile.write("\n") print current_file, H.hexdigest() </code></pre>
2
Receive all notifications for some apps in a single app(Android & IOS)
<p>First of all, I'm not a mobile dev. I would like to know whether it is possible to get notified in a different mobile app when other apps receive notifications in the same mobile? If yes, please give me an overview about that.</p> <p>Any help is appreciated</p> <p>P.S: I'm a web dev so I would be able to understand intercepting http requests</p>
2
Correct procedure for restarting local MongoDB when Mongoose schema is changed
<p>Hi all I'm new to learning how to develop with Node.js using Mongoose and Express. I have been having some issues with Mongodb not correctly reflecting my schema changes.</p> <p>For example, I have written a model that supposedly auto-increment <code>_id</code> by 1 starting from 0 when each new document is inserted. I'm testing a few ways to do this model and so I'm constantly inserting different data.</p> <p>I drop the collection each time to try to reinsert the data. However, <code>_id</code> instead of starting at 0, it starts at the previous largest <code>_id</code>. </p> <p>This is just one of the issues that I have encountered. Some other similar Schema changes that I did on the fly also were not reflected.</p> <p>I tried the following:</p> <ul> <li>Ending npm/nodemon</li> <li>Ctrl+C from <code>mongo</code></li> <li>shutdownServer from <code>mongo</code></li> </ul> <p>Is there something else that I need to shut down completely then restart before mongoose reflects the newest form of the schema? Thanks!</p>
2
Guzzle with telegram Bot API - 'GetMe' method not displaying a user object
<p>I have the code</p> <pre><code>public function getClient(){ $token = getenv('TELEGRAM_TOKEN'); $uri = 'https://api.telegram.org/bot'.$token.'/'; $client = new Client(['base_url' =&gt; $uri]); return $client; } public function getMyBot(){ $client = $this-&gt;getClient(); $response = $client-&gt;get( '/getMe' ); dd($response); } </code></pre> <p>But instead of returning the user object like stated in the <a href="https://core.telegram.org/bots/api#getme" rel="nofollow">docs</a>, I get shown a 'response' object instead.</p> <pre><code>Response {#188 ▼ -reasonPhrase: "OK" -statusCode: 200 -effectiveUrl: "https://core.telegram.org/bots" -headers: array:9 [▼ "server" =&gt; array:1 [▶] "date" =&gt; array:1 [▶] "content-type" =&gt; array:1 [▶] "content-length" =&gt; array:1 [▶] "connection" =&gt; array:1 [▶] "pragma" =&gt; array:1 [▶] "cache-control" =&gt; array:1 [▶] "x-frame-options" =&gt; array:1 [▶] "strict-transport-security" =&gt; array:1 [▶] ] -headerNames: array:9 [▼ "server" =&gt; "Server" "date" =&gt; "Date" "content-type" =&gt; "Content-Type" "content-length" =&gt; "Content-Length" "connection" =&gt; "Connection" "pragma" =&gt; "Pragma" "cache-control" =&gt; "Cache-control" "x-frame-options" =&gt; "X-Frame-Options" "strict-transport-security" =&gt; "Strict-Transport-Security" ] -body: Stream {#189 ▼ -stream: :stream {@280 ▶} -size: null -seekable: true -readable: true -writable: true -uri: "php://temp" -customMetadata: [] } -protocolVersion: "1.1" } </code></pre> <p>Anyway to obtain the user object? I am using php 5.4 with Guzzle 5.3, and laravel 5.0.</p> <p>Edit: I tried using the getBody() method as well as getBody->getContents() method but it doesn't work, getBody will just show the streams part of the response, getContents will give a weird HTML file.</p> <p>JSON_DECODE doesn't work as well, it returns error code 4 which is JSON_ERROR_SYNTAX. Is the response supposed to be a JSON form?</p>
2
How can I access the configuration pool in Symfony Sonata in the Admin class?
<p>I have a select (or a choice) field that should get all options from a function that returns an array.</p> <p>This is the line that defines the choice field;</p> <pre><code>-&gt;add('possibilities', 'choice', array('choices' =&gt; Crud::enumStatus())) </code></pre> <p>And this is the enumStatus function;</p> <pre><code>public static function enumStatus() { return array( '1' =&gt; 'Awaiting Approval', '2' =&gt; 'Partly Approved', '3' =&gt; 'Approved', '4' =&gt; 'Disapproved', '5' =&gt; 'Complete' ); } </code></pre> <hr> <p>What I explained above works perfectly. But what I actually want doesn't work. The principals stay the same.</p> <p>This is what I want;</p> <pre><code>-&gt;add('possibilities', 'choice', array('choices' =&gt; Crud::getUsers(array('Marketing', 'Human Resource Management')))) </code></pre> <p>And the function in the same class as the one mentioned above;</p> <pre><code>public function getUsers($roles) { $queryBuilder = $this-&gt;getConfigurationPool()-&gt;getContainer()-&gt;get('doctrine')-&gt;getManager('admin') -&gt;createQueryBuilder(); $queryBuilder-&gt;select('u.id, u.name') -&gt;from('Qi\Bss\BaseBundle\Entity\Admin\User', 'u') -&gt;innerJoin('u.businessRoles', 'r') -&gt;where('r.name IN (:roles)') -&gt;setParameter('roles', $roles) -&gt;orderby('u.name'); $result = $queryBuilder-&gt;getQuery()-&gt;getResult(); $users = array(); foreach ($result as $key =&gt; $value) { $users[$value['id']] = $value['name']; } return $users; } </code></pre> <hr> <p>The error when trying what I want;</p> <blockquote> <p>Attempted to call method "getConfigurationPool" on class "Xx\Yyy\QqqBundle\Controller\OrderController".</p> </blockquote> <p>The controller that is mentioned in the error message is the controller where the ->add() is for my form, not where those two functions is.</p> <p>Why does the first one work, but the second one doesn't? Can somebody please explain this to me? Is it something to do with the <code>static</code> in the one function? And how can I then resolve this issue? What is the configurationPool and how do get it?</p> <p>I make use of Sonata Admin Bundle and Symfony.</p>
2
RijndaelManaged - encrypt in C# and decrypt in Java
<p>I have c sharp code snippet for encryption which uses .Key file for key and my requirement is to decrypt the encrypted text using same key in android, having problem</p> <pre><code>public static byte[] AES_Encrypt(byte[] bytesToBeEncrypted, byte[] passwordBytes) { byte[] encryptedBytes = null; // Set your salt here, change it to meet your flavor: // The salt bytes must be at least 8 bytes. byte[] saltBytes = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8 }; using (MemoryStream ms = new MemoryStream()) { using (RijndaelManaged AES = new RijndaelManaged()) { AES.KeySize = 256; AES.BlockSize = 128; var key = new Rfc2898DeriveBytes(passwordBytes, saltBytes, 1000); AES.Key = key.GetBytes(AES.KeySize / 8); AES.IV = key.GetBytes(AES.BlockSize / 8); AES.Mode = CipherMode.CBC; using (var cs = new CryptoStream(ms, AES.CreateEncryptor(), CryptoStreamMode.Write)) { cs.Write(bytesToBeEncrypted, 0, bytesToBeEncrypted.Length); cs.Close(); } encryptedBytes = ms.ToArray(); } } return encryptedBytes; } </code></pre>
2
Call Magic methods in Eloquent laravel 5.2
<p>i try use __call magic method for make dynamic method in laravel Eloquent. i have blog and blog_translations table and TITLE,CONTENT must be load from blog_translations table .</p> <blockquote> <pre><code>public function translations($lang = null) { if(empty($lang)) { if (!empty(Lang::getLocale())) { $language = Lang::getLocale(); } else { $language = Config::get('app.fallback_locale'); } }else{ $language = $lang; } return $this-&gt;hasMany(Blog_Translation::class)-&gt;where('locale', $language); } public function __call($method,$arg) { $filed = str_replace('get','',$method); if(sizeof($arg) &gt;= 1){ $lang = $arg[0]; }else { $lang = ''; } return $this-&gt;translations($lang)-&gt;where('name',$filed)-&gt;first()-&gt;text; } </code></pre> </blockquote> <p>in controller :</p> <blockquote> <pre><code> $blog = Blog::find(1); return $blog-&gt;getTITLE(); </code></pre> </blockquote> <p>error :</p> <blockquote> <p>Undefined property: Illuminate\Database\Eloquent\Relations\HasMany::$id</p> </blockquote> <p>with remove __call function relationship work good.</p>
2
Problems with SSH ProxyCommand
<p>I have some problems with the ssh proxycommand. The authentication on the proxy works fine, but when i want to login to the remote-host it fails. The problem seems to be, that the proxy tries to login with my local rsa_key and not with the key stored on the proxy. Is there a way to fix this?</p> <h1>This is what I want:</h1> <p>Local -- local rsa --&gt; Proxy -- proxy rsa --&gt; host</p> <h1>The Config-file I use:</h1> <pre><code>Host 192.168.178.32 HostName 192.168.178.32 User user Port 22 IdentityFile ~/.ssh/id_rsa.pub Host 192.168.178.30 HostName 192.168.178.30 User user Port 22 IdentityFile home/user/.ssh/id_rsa.pub ProxyCommand ssh -W %h:%p -F ssh_config -p 22 192.168.178 </code></pre>
2
How to call Fragment inside a Fragment
<p>I have created a fragment, and used this inside another Fragment layout.</p> <p>This is the XML of my layout.</p> <pre><code>&lt;WebView android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/wv_facebook" &gt; &lt;/WebView&gt; &lt;fragment class="com.loading.LoadingAnimation" android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/wv_facebook_loadingAnimation" /&gt; </code></pre> <p>Now i want to get the ID of this <code>fragment</code>. I used following procedure but i am getting <code>incompatible type</code> error message. </p> <pre><code>Loading Animation loadingAnimation; loadingAnimation = (LoadingAnimation) getFragmentManager().findFragmentById(R.id.wv_facebook_loadingAnimation); </code></pre> <blockquote> <p>Required <code>LoadingAnimation</code> Found android.support.v4.app.fragment</p> </blockquote>
2
Sails.js downloading file
<p>I'm beginner in <code>sails.js</code> and I need to add some logic to existing server. I need to retrieve image from shared network, so I added <code>ImageController.js</code> and action in it:</p> <pre><code>module.exports = { download: function(req, res) { var run = req.param('run'); var test = req.param('test'); var file = req.param('file'); var path = util.format('\\\\tch-smain\\Share\\AutoTest\\Screenshots\\%s\\%s\\%s.jpeg', run, test, file); fileAdapter.read(path) .on('error', function (err){ return res.serverError(err); }) .pipe(res); } }; </code></pre> <p>Then I registered route in <code>config\routes.js</code>:</p> <pre><code>'/img': 'ImageController.download' </code></pre> <p>But when I trying to execute <code>GET /img?run=a&amp;test=b&amp;file=c</code> I get 500 error <strong>Internal Server Error. Something isn't right here</strong>. But file on <code>\\tch-smain\Share\AutoTest\Screenshots\a\b\c.jpeg</code> exists</p>
2
Returning a string or an Int depending on input
<p>How do I write a function that takes as input an <code>Int</code> and returns that <code>Int</code> if it is <code>&gt; 0</code> or otherwise return a dash <code>"-"</code> if it is <code>&lt; 0</code>. I understand that Haskell is strict with its types, but is there a way around this?</p>
2
Is there a way to match Regex based on previous capture group, not captured previously?
<p>Okay, so the task is that there is a string that can either look like <code>post</code>, or <code>post put</code> or even <code>get put post</code>. All of these must be matched. Preferably deviances like <code>[space]post</code>, or <code>get[space]</code> should not be matched.</p> <p>Currently I came up with this </p> <pre><code>^(post|put|delete|get)(( )(post|put|delete|get))*$ </code></pre> <p>However I'm not satisfied with it, because I had to specify <code>(post|put|delete|get)</code> twice. It also matches duplications like <code>post post</code>.</p> <p>I'd like to somehow use a backreference(?) to the first group so that I don't have to specify the same condition twice. </p> <p>However, backreference <code>\1</code> would help me <strong>only</strong> match <code>post post</code>, for example, and that's the opposite of what I want. I'd like to match a word in the first capture group that was <strong>NOT</strong> previously found in the string.</p> <p>Is this even possible? I've been looking through SO questions, but my Google-fu is eluding me.</p>
2
Xcode 8 sets frame size differently. How do I find more details?
<p>In several places in my application I get zero frame sizes where I used to get a frame. This impacted me especially when creating round objects by doing a cornerRadius of <code>size/2</code>.</p> <p>For example, in Xcode 7 this worked fine:</p> <pre><code>class AvatarUIButton: UIButton { required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) layer.masksToBounds = true layer.cornerRadius = bounds.size.width / 2 } } </code></pre> <p>But now in Xcode 8 I have to do this:</p> <pre><code>class AvatarUIButton: UIButton { override var bounds: CGRect { didSet { layer.cornerRadius = bounds.size.width / 2 }} required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) self.layer.masksToBounds = true } } </code></pre> <p>In this example, the change is arguably better/more obvious. I have another situation that is much less isolated involving a 0 frame on TableHeaderView that is only for xcode 8.</p> <p>I'm looking for release notes, mailing list discussion, or similar that discusses a change in ordering of frame size determination so I can figure out what changed and how I can fix it.</p>
2
Hide a view when textView is too long
<p>I'm looking to hide a view if my textview is too long and it starts to touch it, how would I go about doing this? So for example like this is okay:</p> <p><a href="https://i.stack.imgur.com/ooEqe.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ooEqe.png" alt="Normal Username length"></a></p> <p>But when it's a long username and the length is nearer the time stamp I want to hide the timestamp, how would I go about doing this? Cannot think of it for the life of me! </p> <p><strong>EDIT:</strong> My current layout is like this </p> <p>list_item_post.xml</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:background="#FFFFFF"&gt; &lt;LinearLayout android:id="@+id/opBackground" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/white" android:orientation="vertical"&gt; &lt;LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"&gt; &lt;LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical"&gt; &lt;TextView android:id="@+id/authorTextView" android:layout_width="wrap_content" android:layout_height="34dp" android:layout_gravity="start|center" android:layout_marginStart="10dp" android:layout_marginTop="15dp" android:background="@drawable/textview_corner_radius" android:fontFamily="sans-serif-condensed" android:paddingBottom="8dp" android:paddingEnd="18dp" android:paddingStart="18dp" android:paddingTop="8dp" android:textColor="@android:color/white" android:textStyle="bold" android:gravity="center" /&gt; &lt;View android:id="@+id/postTriangle" android:layout_width="15dp" android:layout_height="15dp" android:background="@drawable/ic_purple_triangle" android:layout_marginStart="12dp" android:layout_marginTop="-5dp"/&gt; &lt;/LinearLayout&gt; &lt;TextView android:id="@+id/dateTime" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="0.8" android:gravity="end" android:layout_gravity="center" android:textColor="@color/purple" android:layout_marginTop="8dp" android:textSize="12sp"/&gt; &lt;ImageButton android:id="@+id/morePostOptions" android:layout_marginEnd="8dp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/ic_more" android:layout_gravity="center" android:layout_marginTop="8dp"/&gt; &lt;/LinearLayout&gt; &lt;TextView android:id="@+id/postText" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="5dp" android:layout_marginStart="27dp" android:layout_marginEnd="25dp" android:layout_marginBottom="25dp" android:textColor="@android:color/black" android:textSize="14sp" android:lineSpacingExtra="5dp"/&gt; &lt;ImageView android:id="@+id/imagePost" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_margin="5dp" /&gt; &lt;/LinearLayout&gt; &lt;/LinearLayout&gt; </code></pre> <p>Thanks in advance, can provide anything if you want to see it!</p>
2
Toolbar title not changing in Android
<p>I am trying to set the title of Toolbar in Android but the app crashes (null pointer exception). I have tried many stackoverflow same question but none seemed to work for me. I used the code below</p> <pre><code>toolbar = (Toolbar) findViewById(R.id.toolBarDataProvider); setSupportActionBar(toolbar); getSupportActionBar().setTitle("Notice"); </code></pre> <p><strong>Logcat</strong></p> <pre><code>Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.v7.app.ActionBar.setTitle(java.lang.CharSequence)' on a null object reference at com.akapoor.kiittimetabletest1.Notice.onCreate(Notice.java:31) </code></pre> <p><strong>XML</strong></p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context="com.akapoor.kiittimetabletest1.Notice"&gt; &lt;include android:id="@+id/include" layout="@layout/toolbar_data_provider" android:layout_width="match_parent" android:layout_height="wrap_content" /&gt; &lt;LinearLayout android:layout_margin="10dp" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:weightSum="10"&gt; &lt;ScrollView android:id="@+id/scrollView2" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="9"&gt; &lt;TextView android:id="@+id/tvServerText" android:layout_width="match_parent" android:layout_height="match_parent" android:textSize="25dp" android:textColor="#000000" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" /&gt; &lt;/ScrollView&gt; &lt;Button android:id="@+id/bServer" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:text="Refresh" /&gt; &lt;/LinearLayout&gt; </code></pre> <p></p> <p><strong>toolbar_data_provider.xml</strong></p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/toolBarDataProvider" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="?attr/colorPrimary" android:fitsSystemWindows="true" android:minHeight="?attr/actionBarSize" app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"&gt; &lt;/android.support.v7.widget.Toolbar&gt; </code></pre>
2
SAPUI5: Cannot read property '0' of undefined
<p>What are the possible errors to get this error message? </p> <p><a href="https://i.stack.imgur.com/RpWhw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RpWhw.png" alt="enter image description here"></a></p> <p>I tried to google but it says it happens in the javascript file where the getelementbyid returns null. But I checked all the element ids and they are correct... I am thinking it could be some errors regarding to the wizard section in xml. </p>
2
create custom attribute for class property
<p>I am working on console application. I want to make sure that when values assigned to my class properties it should do basic validation. I read about "creating custom attribute" but not able to understand how to implement in my case. for e.g. </p> <pre><code>public class MyClass { [Required] public string id; [ContainsNumeric] public int cost; [ContainsChar] ... [ContainsDate] .... } </code></pre> <p>I created Required attribute and ContainsNumeric only class but don't know how to access actual class properties within those classes.</p> <pre><code>class ContainsNumericAttribute : Attribute { public ContainsNumericAttribute() : base() { ????? } } class RequiredAttribute : Attribute { public RequiredAttribute() : base() { ??? } } </code></pre> <p>Please help me with example. </p>
2
DecimalFormat is not working properly
<p>I am trying to apply formatting (, after 3 digits and rounding after 4 digits), using below code - </p> <pre><code>double a = 1231254125412512.231515235346; NumberFormat formatter = new DecimalFormat("#,###"); formatter.setRoundingMode(RoundingMode.HALF_UP); formatter.setMinimumFractionDigits(4); formatter.setMaximumFractionDigits(4); System.out.println("Number : " + formatter.format(a)); </code></pre> <p>Above code is working properly for the number <code>-54125412512.231515235346</code> (result was <code>-54,125,412,512.2315</code>).</p> <p>But it is not working for the number <code>-1231254125412512.231515235346</code> (result <code>-1,231,254,125,412,512.2000</code>).</p>
2
Bootstrap grid putting text on top of each other instead of next to
<p>I can't get my bootstrap grid code to place the work test on the left of Choose your bicycle. instead test is in the line above Choose your bicycle. Can anyone tell me why this is happening?</p> <p>HTML</p> <pre><code> &lt;!DOCTYPE html&gt; &lt;html ng-app='formApp'&gt; &lt;head&gt; &lt;title&gt;Bicycle App&lt;/title&gt; &lt;link rel="stylesheet" href="bower_components/font-awesome/css/font-awesome.min.css"&gt; &lt;link href="app.css" rel="stylesheet"&gt; &lt;/head&gt; &lt;body&gt; &lt;div class="header"&gt; &lt;div class="container"&gt; &lt;div class='row'&gt; &lt;div class='col-md-12'&gt; &lt;i class="fa fa-bicycle" aria-hidden="true"&gt;&lt;span&gt;&amp;nbsp;{{"Andy's Bike Shop"}}&lt;/span&gt;&lt;/i&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;&lt;!--Header Container--&gt; &lt;/div&gt; &lt;div class="bikeSelector"&gt; &lt;div class="container"&gt; &lt;div class='row'&gt; &lt;div class="col-md-3"&gt;test&lt;/div&gt; &lt;div class='col-offset-3 col-md-6'&gt; Choose your bicycle &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;script src="bower_components/angular/angular.js"&gt;&lt;/script&gt; &lt;script src="app.js"&gt;&lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p><a href="https://i.stack.imgur.com/bs7F2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bs7F2.png" alt="enter image description here"></a></p>
2
Video recording in background-Android
<p>Through various sources on stackoverflow or other places i gathered up following code to record video in background but i am not able to initiate my RecorderService.</p> <p>ACTIVITY -1 Variables:</p> <pre><code>mSurfaceView = (SurfaceView) findViewById(R.id.surfaceView1); mSurfaceHolder = mSurfaceView.getHolder(); mSurfaceHolder.addCallback(this); mSurfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); </code></pre> <p>Calling the Recorder Service:</p> <pre><code>@Override public void surfaceCreated(SurfaceHolder holder) { Log.e("Suface created - intent", "recorder service"); Intent intent2 = new Intent(AttendantActivity.this, RecorderService.class); startService(intent2); } </code></pre> <p>RecorderService - Source : <a href="https://github.com/pickerweng/CameraRecorder" rel="nofollow">https://github.com/pickerweng/CameraRecorder</a></p> <pre><code> public class RecorderService extends Service { private static final String TAG = "RecorderService"; private SurfaceView mSurfaceView; private SurfaceHolder mSurfaceHolder; public static Camera mServiceCamera; private boolean mRecordingStatus; private MediaRecorder mMediaRecorder; @Override public void onCreate() { mRecordingStatus = false; mServiceCamera = AttendantActivity.mCamera; mSurfaceView = AttendantActivity.mSurfaceView; mSurfaceHolder = AttendantActivity.mSurfaceHolder; Log.e("Recorder", "Service started"); super.onCreate(); } @Override public IBinder onBind(Intent intent) { return null; } @Override public int onStartCommand(Intent intent, int flags, int startId) { super.onStartCommand(intent, flags, startId); if (mRecordingStatus == false) startRecording(); return START_STICKY; } @Override public void onDestroy() { stopRecording(); mRecordingStatus = false; super.onDestroy(); } public boolean startRecording() { Toast.makeText(getBaseContext(), "Recording Started", Toast.LENGTH_SHORT).show(); mServiceCamera = Camera.open(); Camera.Parameters params = mServiceCamera.getParameters(); mServiceCamera.setParameters(params); Camera.Parameters p = mServiceCamera.getParameters(); final List&lt;Size&gt; listPreviewSize = p.getSupportedPreviewSizes(); Size previewSize = listPreviewSize.get(0); p.setPreviewSize(previewSize.width, previewSize.height); mServiceCamera.setParameters(p); try { mServiceCamera.setPreviewDisplay(mSurfaceHolder); mServiceCamera.startPreview(); } catch (IOException e) { Log.e(TAG, e.getMessage()); e.printStackTrace(); } mServiceCamera.unlock(); mMediaRecorder = new MediaRecorder(); mMediaRecorder.setCamera(mServiceCamera); mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC); mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA); mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP); mMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); mMediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264); mMediaRecorder.setOutputFile(Environment.getExternalStorageDirectory().getPath() +"/"+ new Date(System.currentTimeMillis()).toString()+"video.mp4"); mMediaRecorder.setVideoSize(320, 240); if(mSurfaceHolder != null) mMediaRecorder.setPreviewDisplay(mSurfaceHolder.getSurface()); try { mMediaRecorder.prepare(); mMediaRecorder.start(); } catch (IOException e) { e.printStackTrace(); } mRecordingStatus = true; return true; } public void stopRecording() { Toast.makeText(getBaseContext(), "Recording Stopped", Toast.LENGTH_SHORT).show(); try { mServiceCamera.reconnect(); } catch (IOException e) { e.printStackTrace(); } try { mMediaRecorder.stop(); Log.e("[AUDIO---]", "recording stopped-"); }catch (RuntimeException e){ Log.e("Exception", e.getMessage()+"-"); } if(mMediaRecorder!=null) { mMediaRecorder.reset(); // You can reuse the object by going back to setAudioSource() step mServiceCamera.stopPreview(); mMediaRecorder.release(); } mServiceCamera.release(); mServiceCamera = null; } } </code></pre>
2
TypeError: Cannot read property '$valid' of undefined on using ng-submit
<p>I referred <a href="https://stackoverflow.com/questions/34647934/angular-js-form-validation-inside-tabset-give-error-typeerror-cannot-read-pro">Angular JS Form validation inside tabset give error : TypeError: Cannot read property &#39;$valid&#39; of undefined</a> but its not exactly what am looking for. </p> <p>I have this html code,</p> <pre><code>&lt;form name="userForm" ng-submit="submit()" novalidate&gt; &lt;input type="text" class="form-control" ng-model="user.name" required&gt; &lt;button type="submit" class="btn btn-primary" ng-disabled="!userForm.$valid"&gt;Submit&lt;/button&gt; &lt;/form&gt; </code></pre> <p>And my js is something like,</p> <pre><code>$scope.submitForm = function () { // check to make sure the form is completely valid if ($scope.userForm.$valid) { alert('its working'); } }; </code></pre> <p>I get this error. Is there a way to resolve this when am using <code>ng-submit</code>. </p>
2
Git Permission Issue in Terminal
<ol> <li>Team Lead Created A repository</li> <li>Pushed Two files with permission 655 and 755 respectively.</li> <li>Clone the repository by another team member A by terminal.</li> <li>Trying to edit the file in sublime text and its showing <strong>permission denied</strong> message upon saving.</li> <li>gave 777 permission to folder with recursive mode and finish the editing</li> <li>Push the changes by team member A and completes</li> <li>Team Lead pull the changes via terminal,got the latest file and again changed the permission to 755.</li> <li>Only work on file after making the permission to 777.</li> </ol> <p>Why this happening like this in ubuntu ? The permission switching is making problems for me.. Any Idea for recovering this issue ?</p>
2
WildFly DataSource Services which failed to start
<p>I configured a DataSource using WildFly to open a connection, but when I run WildFly I got this error:</p> <pre><code>11:47:46,874 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 60) MSC000001: Failed to start service jboss.persistenceunit."services.war#DataSourceBLX": org.jboss.msc.service.StartException in service jboss.persistenceunit."services.war#DataSourceBLX": java.lang.ClassCastException: org.dom4j.DocumentFactory cannot be cast to org.dom4j.DocumentFactory at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:172) at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:117) at org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:667) at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:182) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) at org.jboss.threads.JBossThread.run(JBossThread.java:320) Caused by: java.lang.ClassCastException: org.dom4j.DocumentFactory cannot be cast to org.dom4j.DocumentFactory at org.dom4j.DocumentFactory.getInstance(DocumentFactory.java:97) at org.hibernate.internal.util.xml.XMLHelper$1.doWork(XMLHelper.java:33) at org.hibernate.internal.util.xml.XMLHelper$1.doWork(XMLHelper.java:27) at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.workWithClassLoader(ClassLoaderServiceImpl.java:342) at org.hibernate.internal.util.xml.XMLHelper.&lt;init&gt;(XMLHelper.java:26) at org.hibernate.envers.boot.internal.EnversServiceImpl.initialize(EnversServiceImpl.java:115) at org.hibernate.envers.boot.internal.AdditionalJaxbMappingProducerImpl.produceAdditionalMappings(AdditionalJaxbMappingProducerImpl.java:99) at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:288) at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:847) at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:874) at org.jboss.as.jpa.hibernate5.TwoPhaseBootstrapImpl.build(TwoPhaseBootstrapImpl.java:44) at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:154) ... 7 more 11:47:47,776 INFO [org.jboss.as.controller] (Controller Boot Thread) WFLYCTL0183: Service status report WFLYCTL0186: Services which failed to start: service jboss.persistenceunit."services.war#DataSourceBLX": org.jboss.msc.service.StartException in service jboss.persistenceunit."services.war#DataSourceBLX": java.lang.ClassCastException: org.dom4j.DocumentFactory cannot be cast to org.dom4j.DocumentFactory </code></pre> <hr> <p>Here's my persistence.xml</p> <pre><code>&lt;persistence-unit name="DataSourceBLX"&gt; &lt;provider&gt;org.hibernate.jpa.HibernatePersistenceProvider&lt;/provider&gt; &lt;jta-data-source&gt;java:jboss/datasources/DataSourceBLX&lt;/jta-data-source&gt; &lt;class&gt;com.brq.blx.entity.Alteracao&lt;/class&gt; &lt;class&gt;com.brq.blx.entity.Anuncio&lt;/class&gt; &lt;class&gt;com.brq.blx.entity.Avaliacao&lt;/class&gt; &lt;class&gt;com.brq.blx.entity.Categoria&lt;/class&gt; &lt;class&gt;com.brq.blx.entity.Contato&lt;/class&gt; &lt;class&gt;com.brq.blx.entity.Endereco&lt;/class&gt; &lt;class&gt;com.brq.blx.entity.Imagem&lt;/class&gt; &lt;class&gt;com.brq.blx.entity.TipoUsuario&lt;/class&gt; &lt;class&gt;com.brq.blx.entity.Usuario&lt;/class&gt; &lt;properties&gt; &lt;property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect" /&gt; &lt;property name="hibernate.show_sql" value="true" /&gt; &lt;/properties&gt; &lt;/persistence-unit&gt; </code></pre> <p>And in my standalone</p> <pre><code>&lt;datasource jndi-name="java:jboss/datasources/DataSourceBLX" pool-name="OracleXE" enabled="true"&gt; &lt;connection-url&gt;jdbc:oracle:thin:@10.2.8.224:1521:fundoshomo&lt;/connection-url&gt; &lt;driver&gt;oracle&lt;/driver&gt; &lt;pool&gt; &lt;min-pool-size&gt;1&lt;/min-pool-size&gt; &lt;max-pool-size&gt;70&lt;/max-pool-size&gt; &lt;prefill&gt;true&lt;/prefill&gt; &lt;/pool&gt; &lt;security&gt; &lt;user-name&gt;stags&lt;/user-name&gt; &lt;password&gt;123&lt;/password&gt; &lt;/security&gt; &lt;/datasource&gt; </code></pre> <p>.</p> <pre><code> &lt;driver name="oracle" module="com.oracle"&gt; &lt;driver-class&gt;oracle.jdbc.driver.OracleDriver&lt;/driver-class&gt; &lt;/driver&gt; </code></pre> <p>I can't see what the problem is, so if you guys could help me, I would be grateful.</p>
2
How to assign unique id to each select box for the following scenario
<p>I have used below code to develop dynamic select box which has Unique id's.i.e In single click i am generating two select boxes.</p> <pre><code>$(function () { var nextRowID = 0; var nextRowID1 = 1; $("body").on("click", "#btnAdd", function () { var id = ++nextRowID; var id1 = ++nextRowID1; var partipiansRow = '&lt;div&gt;&lt;select class="drop_dwn_mult" id="name' + id + '"&gt;&lt;option&gt;Sample1&lt;/option&gt;&lt;option&gt;Sample2&lt;/option&gt;&lt;option&gt;Sample3&lt;/option&gt;&lt;option&gt;Sample4&lt;/option&gt;&lt;/select&gt;&lt;select class="drop_dwn_mult" id="name' + id1 + '"&gt;&lt;option&gt;Sample1&lt;/option&gt;&lt;option&gt;Sample2&lt;/option&gt;&lt;option&gt;Sample3&lt;/option&gt;&lt;option&gt;Sample4&lt;/option&gt;&lt;/select&gt;' + '&lt;i class="fa fa-minus-square remove" aria-hidden="true"&gt;&lt;/i&gt;&lt;i class="fa fa-plus-square" aria-hidden="true" id="btnAdd"&gt;&lt;/i&gt;&lt;/div&gt;'; $('#TextBoxContainer').append(partipiansRow); }); </code></pre> <p>But the ouput i am getting as below as </p> <pre><code> &lt;div id="TextBoxContainer"&gt; &lt;!--Textboxes will be added here --&gt; &lt;div&gt;&lt;select class="drop_dwn_mult" id="name1"&gt;&lt;option&gt;Sample1&lt;/option&gt;&lt;option&gt;Sample2&lt;/option&gt;&lt;option&gt;Sample3&lt;/option&gt;&lt;option&gt;Sample4&lt;/option&gt;&lt;/select&gt;&lt;select class="drop_dwn_mult" id="name2"&gt;&lt;option&gt;Sample1&lt;/option&gt;&lt;option&gt;Sample2&lt;/option&gt;&lt;option&gt;Sample3&lt;/option&gt;&lt;option&gt;Sample4&lt;/option&gt;&lt;/select&gt;&lt;i class="fa fa-minus-square remove" aria-hidden="true"&gt;&lt;/i&gt;&lt;i class="fa fa-plus-square" aria-hidden="true" id="btnAdd"&gt;&lt;/i&gt;&lt;/div&gt; &lt;div&gt;&lt;select class="drop_dwn_mult" id="name2"&gt;&lt;option&gt;Sample1&lt;/option&gt;&lt;option&gt;Sample2&lt;/option&gt;&lt;option&gt;Sample3&lt;/option&gt;&lt;option&gt;Sample4&lt;/option&gt;&lt;/select&gt;&lt;select class="drop_dwn_mult" id="name3"&gt;&lt;option&gt;Sample1&lt;/option&gt;&lt;option&gt;Sample2&lt;/option&gt;&lt;option&gt;Sample3&lt;/option&gt;&lt;option&gt;Sample4&lt;/option&gt;&lt;/select&gt;&lt;i class="fa fa-minus-square remove" aria-hidden="true"&gt;&lt;/i&gt;&lt;i class="fa fa-plus-square" aria-hidden="true" id="btnAdd"&gt;&lt;/i&gt;&lt;/div&gt;&lt;/div&gt; </code></pre> <p>In the above HTML totally i have four select boxes in which i cant able to generate unique ID's.</p> <p>Please help me to generate unique id's for all select boxes.</p>
2
Cannot cross-compile Qt 5.7 for Raspberry PI because it "requires a C++11 compiler"
<p>I want to cross compile qt5 on RPi2 according to this <a href="http://wiki.qt.io/RaspberryPi2EGLFS" rel="nofollow">RaspberryPi2EGLFS</a> when I want to configure in step7 I see this error and I don't have any idea how to solve it.</p> <pre><code>. . collect2: error: ld returned 1 exit status Makefile:91: recipe for target 'c++11' failed make: *** [c++11] Error 1 C++11 disabled. ERROR: Qt requires a C++11 compiler and yours does not seem to be that. Please upgrade. </code></pre> <p>I use antergos x64.</p>
2
Django: 'unicode' object has no attribute 'tzinfo' error using django-pyodbc-azure
<p>I have been asked to create a simple web front-end for an internal MSSQL database. I'm using django-pyodbc-azure .</p> <p>I finally got everything configured and running but now when I try to log in to the admin page I get a <strong>'unicode' object has no attribute 'tzinfo'</strong> error. I tried the suggestion <a href="https://stackoverflow.com/questions/35758154/django-unicode-object-has-no-attribute-tzinfo-production-server-only/38229812?noredirect=1#comment63881816_38229812">here</a> but it didn't seem to help. Any suggestions are very welcome!</p>
2
Android - Record Video and Set Video Size (Dimensions)
<p>I'm in the process of refactoring a piece of code that records videos (from the camera) ranging usually between 3 and 30 seconds in order to decrease the overall size (in bytes) of the video.</p> <p>We were previously using <code>CamcorderProfile</code>, but it does not provide enough granularity for our application so I have now transitioned to manually adjusting all of the settings (audio source, video source, video frame rate, audio encoder, etc).</p> <p>The issue is I cannot find a reliable method for selecting the optimal video size since there does not (to my knowledge) exist a universal list of sizes that all Android devices support. I would like the video to be as close to 480x360px as possible since we push our video to Amazon Elastic Transcoder, which makes the videos 480x360px in a variety of formats (mp4, webm, etc).</p> <p>Below is a snippet of code of my general idea:</p> <pre><code>List&lt;Camera.Size&gt; sizes = camera.getParameters().getSupportedVideoSizes(); Camera.Size s; // // select size from sizes??? // recorder = new MediaRecorder(); camera.stopPreview(); camera.unlock(); recorder.setCamera(camera); // configure recorder recorder.setVideoSource(MediaRecorder.VideoSource.CAMERA); recorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER); recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4); // WHAT IS THE SIZE?? recorder.setVideoSize(s.width, s.height); recorder.setVideoFrameRate(15); recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); recorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264); </code></pre> <p>I have looked at a variety of posts on here as well as the Android Compatibility Definition Documents for 4.4 - 6.0.</p> <p>Any ideas or resources are greatly appreciated.</p>
2
pushViewController slowly
<p>mycode:</p> <p><code>self.navigationController?.pushViewController(vc, animated: false) NSLog("finish pushViewController")</code></p> <pre><code>override func viewDidLoad() { NSLog("start viewDidLoad") super.viewDidLoad() NSLog("end viewDidLoad") } </code></pre> <p>log : </p> <p><code>2016-07-18 15:40:55.060 KaXin[64190:12458086] finish pushViewController 2016-07-18 15:40:56.470 KaXin[64190:12458086] start viewDidLoad 2016-07-18 15:40:56.471 KaXin[64190:12458086] end viewDidLoad</code></p> <p>between "finish pushViewController" and "start viewDidLoad" it takes 1.4 seconds.</p> <p>what does it does? </p> <p>how do I fix it?</p> <p>ios 9.2, xcode:7.3</p> <p>only first time push this viewcontroller, it takes long time</p>
2
Drawing a FacetGrid of QQ-plots with seaborn
<p>I am unable to draw a <a href="https://stanford.edu/~mwaskom/software/seaborn/generated/seaborn.FacetGrid.html#seaborn.FacetGrid" rel="nofollow">FacetGrid</a> of <a href="https://en.wikipedia.org/wiki/Q%E2%80%93Q_plot" rel="nofollow">QQ-plots</a> with <a href="https://stanford.edu/~mwaskom/software/seaborn/index.html" rel="nofollow">seaborn</a>.</p> <p>I have a matrix of m rows (observations) and n columns (features), and I want to draw a QQ-plot for each feature (column) to compare it with the normal distribution.</p> <p>So far, my code is like this:</p> <pre><code>import scipy.stats as ss def qqplots(fpath, expr, title): def quantile_plot(x, **kwargs): x = ss.zscore(x) qntls, xr = ss.probplot(x, dist="norm") plt.scatter(xr, qntls, **kwargs) expr_m = pd.melt(expr) expr_m.columns = ["Feature", "Value"] n_feat = len(expr_m["Feature"].value_counts().index) n_cols = int(np.sqrt(n_feat)) + 1 g = sns.FacetGrid(expr_m, col="Feature", col_wrap=n_cols) g.map(quantile_plot, "Value"); plt.savefig(fpath + ".pdf", bbox_inches="tight") plt.savefig(fpath + ".png", bbox_inches="tight") plt.close() qqplots("lognorm_qqplot", np.log2(expr), "Log-normal qqplot") </code></pre> <p>The <code>expr</code> variable is a pandas DataFrame with m rows (observations) and n columns (features).</p> <p>The Exception I get is the following:</p> <pre><code>--------------------------------------------------------------------------- ValueError Traceback (most recent call last) &lt;ipython-input-52-f9333a55702e&gt; in &lt;module&gt;() 39 plt.close() 40 ---&gt; 41 qqplots("lognorm_qqplot", np.log2(expr), "Log-normal qqplot") &lt;ipython-input-52-f9333a55702e&gt; in qqplots(fpath, expr, title) 34 35 g = sns.FacetGrid(expr_m, col="Feature", col_wrap=n_cols) ---&gt; 36 g.map(quantile_plot, "Value"); 37 plt.savefig(fpath + ".pdf", bbox_inches="tight") 38 plt.savefig(fpath + ".png", bbox_inches="tight") /usr/local/lib/python3.5/site-packages/seaborn/axisgrid.py in map(self, func, *args, **kwargs) 726 727 # Draw the plot --&gt; 728 self._facet_plot(func, ax, plot_args, kwargs) 729 730 # Finalize the annotations and layout /usr/local/lib/python3.5/site-packages/seaborn/axisgrid.py in _facet_plot(self, func, ax, plot_args, plot_kwargs) 810 811 # Draw the plot --&gt; 812 func(*plot_args, **plot_kwargs) 813 814 # Sort out the supporting information &lt;ipython-input-52-f9333a55702e&gt; in quantile_plot(y, **kwargs) 25 y = ss.zscore(y) 26 qntls, xr = ss.probplot(y, dist="norm") ---&gt; 27 plt.scatter(xr, qntls, **kwargs) 28 29 expr_m = pd.melt(expr) /usr/local/lib/python3.5/site-packages/matplotlib/pyplot.py in scatter(x, y, s, c, marker, cmap, norm, vmin, vmax, alpha, linewidths, verts, edgecolors, hold, data, **kwargs) 3249 vmin=vmin, vmax=vmax, alpha=alpha, 3250 linewidths=linewidths, verts=verts, -&gt; 3251 edgecolors=edgecolors, data=data, **kwargs) 3252 finally: 3253 ax.hold(washold) /usr/local/lib/python3.5/site-packages/matplotlib/__init__.py in inner(ax, *args, **kwargs) 1810 warnings.warn(msg % (label_namer, func.__name__), 1811 RuntimeWarning, stacklevel=2) -&gt; 1812 return func(ax, *args, **kwargs) 1813 pre_doc = inner.__doc__ 1814 if pre_doc is None: /usr/local/lib/python3.5/site-packages/matplotlib/axes/_axes.py in scatter(self, x, y, s, c, marker, cmap, norm, vmin, vmax, alpha, linewidths, verts, edgecolors, **kwargs) 3838 y = np.ma.ravel(y) 3839 if x.size != y.size: -&gt; 3840 raise ValueError("x and y must be the same size") 3841 3842 s = np.ma.ravel(s) # This doesn't have to match x, y in size. ValueError: x and y must be the same size </code></pre>
2
How can I call a method with parameter mouse event e in another class?
<p>I write the code below and want to call the mousepress method in another class, but I get the error to define parameter mouseevent for where I called it, but I get <code>NullPointerException</code> error when I define a variable mouseevent <code>e</code>.</p> <p>Please help me.</p> <pre><code> public void mousePressed(MouseEvent e , int tankid) { System.out.println("insert which tanks you want to move"); JButton clicked = (JButton)e.getSource(); System.out.println(clicked.getAlignmentX()+"mmmmmmmmmmm"); for(int x = 0; x&lt;board.r; x++) { for(int y = 0;y&lt;board.cc;y++) { if(clicked == board.squares[x][y]) { ImageIcon icon = new ImageIcon("C:/Users/win_10/Desktop/tanks/tank1.png"); board.squares[troops[tankid].getPosition().x][troops[tankid].getPosition().y].setIcon(null); board.squares[x][y].setIcon(icon); map.mapboard[troops[tankid].getPosition().x][troops[tankid].getPosition().y].setBackground(null); troops[i].getPosition().x = x; troops[i].getPosition().x = y; map.mapboard[troops[tankid].getPosition().x][troops[tankid].getPosition().x].add(new JLabel(name)); SwingUtilities.updateComponentTreeUI(map.getContentPane()); System.out.println(x + " "+ y); } } } } </code></pre>
2
Monitoring uwsgi with zabbix
<p>I would like to monitor uwsgi using zabbix. I found that there is some plugin for that:</p> <pre><code>uwsgi --stats-push zabbix:127.0.0.1:10051,myinstance ... </code></pre> <p>but I'm not sure how it is supposed to work. It seems that uwsgi pushes all the stats to the target zabbix but I can't find a description of this stats, hence I don't know how to set item(s) on zabbix.</p> <p>For the moment I don't see anything coming to my zabbix instance.</p>
2
How to find the position of a word in a string / list?
<p>I'm writing a function where the user inputs a word, then inputs a string, and the function identifies all occurrences and the position of that word in a string (although it's actually converted to a list halfway through). </p> <p>The code I have currently is only identifying the first occurrence of the word, and none further. It also doesn't identify the word if the word is the first word in the string, returning an empty list. It will also say the word's actual position - 1, as the first word is counted as zero. </p> <p>I have attempted to curb this problem in two ways, the first of which doing a <code>aString.insert(0, ' ')</code>, the second of which doing <code>for i in __: if i == int: i += 1</code>. Neither of these work. </p> <p>Also, when doing the <code>.insert</code>, I tried putting a character in the space instead of, well, a space (as this part doesn't get printed anyway), but that didn't work.</p> <p>Here is the code:</p> <pre><code>def wordlocator(word): yourWord = word print("You have chosen the following word: " +yourWord) aString = input("What string would you like to search for the given word?") aString = aString.lower() aString = aString.split() b = [(i, j) for i, j in enumerate(aString)] c = [(i, x) for i, x in b if x == yourWord] return c </code></pre> <p>The output I'm looking for is that if someone did...</p> <pre><code>wordlocator("word") "please input a string generic message" "that is a word" "4, word" </code></pre> <p>Currently that would work, but it'd print <code>"3, word"</code>. If the string was <code>"that is a word and this is also a word"</code> then it'd ignore the further occurrence of <code>"word"</code>. edit: Got it working now, used a simpler piece of code. Thanks for your help all!</p>
2
Activator.CreateInstance with an Interface parameter
<p>I have a Reflection method, which I load an Instance of an class with a specific name. I have an abstract class which define my classes. Now I also have an interface in the constructor of this abstract class. It's a bit hard to explain and I'm not sure if it's a correct way to implement my problem. But here is my source code, which should explain the most:</p> <p>Program:</p> <pre><code> private static void Main(string[] args) { int result; if (args.Length &gt; 0) { string jobName = args[0]; Type[] types = Assembly.GetAssembly(typeof(Task)).GetTypes(); foreach (Type type in types) { if (type.Name == jobName) { //Here is my problem. I need my Interface instead of null _job = (Task)Activator.CreateInstance(type, null); } } if (_job != null) { result = _job.Run(args); } } //Dispose the Job _job = null; } </code></pre> <p>Task:</p> <pre><code>public abstract class Task { public IArgument Argument; protected Task(IArgument argument) { Argument = argument; } public int Run(string[] args) { int result; if (SetArguments(args)) { result = Work(); } return result; } protected abstract int Work(); </code></pre> <p>Interface:</p> <pre><code>public interface IArgument { bool SetArguments(string[] args); } </code></pre> <p>Now I can create an "Task" class and an "Argument" class:</p> <pre><code>public class ImportArgument : IArgument { public bool SetArguments(string[] args) { return true; } } public class ImportTask : Task { protected override int Work() { return 1; } public ImportTask(IArgument argument) : base(argument) { Argument = new ArticleImportArgument(); } } </code></pre> <p>What do you guys think. Is there a way where I can create an Instance of the task class with an Interface in the constructor? Is there another way to solve this problem? I could also create an abstract method in my Task class where I have to implement my Interface, but I think the constructor would be a better way.</p>
2
Using EasyPHP Webserver
<p>I'm not sure how one goes about using EasyPHP Webserver. Looking around the internet there doesn't seem to be a lot of materials on the matter. Whenever I try to run a php file from the www folder, a new blank tab appears without output from script code (Simple hello world echo). I'm not sure what the problem could be. My Http server and db server is running.</p> <p>I'm also not sure if EasyPHP devserver is capable of going online. I'm currently in the middle of building an application that requires information to be sent to the server. My android application has been having trouble connecting to the EasyPHP devserver. Will I have more success with EasyPHP Webserver than I will with Devserver?</p>
2
webpack-dev-server not reloading browser
<p>I can't get webpack-dev-server to auto refresh browser, I have to terminate at command line and restart before the browser would load fresh content. This is my webpack config:</p> <pre><code> var webpack = require('webpack'); new webpack.DefinePlugin({ 'process.env': { NODE_ENV: JSON.stringify(process.env.NODE_ENV), }, }) var debug = process.env.NODE_ENV !== "production"; console.log(process.env.NODE_ENV) module.exports = { context: __dirname + "/src", devtool: debug ? "inline-sourcemap" : null, entry: "./js/client.js, module: { loaders: [ { test: /\.jsx?$/, exclude: /(node_modules|bower_components)/, loader: 'babel-loader', query: { presets: ['react', 'es2015', 'stage-0'], plugins: ['react-html-attrs', 'transform-class-properties', 'transform-decorators-legacy'], } } ] }, output: { path: __dirname + "src/", filename: "client.min.js" }, plugins: debug ? [] : [ new webpack.optimize.DedupePlugin(), new webpack.optimize.OccurenceOrderPlugin(), new webpack.optimize.UglifyJsPlugin({ mangle: false, sourcemap: false }), ], }; </code></pre> <p>My package.json:</p> <pre><code> "scripts": { "dev": "./node_modules/.bin/webpack-dev-server --content-base src --inline --hot", "test": "echo \"Error: no test specified\" &amp;&amp; exit 1" </code></pre> <p>I am on Windows and typed npm run dev on command line. I am using latest version of webpack and webpack-dev-server. Cant find anything online that could help.</p> <p>Output:</p> <pre><code>C:\Users\owner\react\basic-react&gt;npm run dev &gt; [email protected] dev C:\Users\owner\react\basic-react &gt; webpack-dev-server --content-base src --inline --hot http://localhost:8080/ webpack result is served from / content is served from C:\Users\owner\react\basic-react\src Hash: 0e903e041e328deb3d40 Version: webpack 1.13.1 Time: 1959ms Asset Size Chunks Chunk Names client.min.js 2.4 MB 0 [emitted] main chunk {0} client.min.js (main) 868 kB [rendered] [0] multi main 52 bytes {0} [built] [1] (webpack)-dev-server/client?http://localhost:8080 2.67 kB {0} [built] [2] ./~/url/url.js 22.3 kB {0} [built] [3] ./~/url/~/punycode/punycode.js 14.6 kB {0} [built] [4] (webpack)/buildin/module.js 251 bytes {0} [built] [5] ./~/querystring/index.js 127 bytes {0} [built] [6] ./~/querystring/decode.js 2.4 kB {0} [built] [7] ./~/querystring/encode.js 2.09 kB {0} [built] [8] ./~/sockjs-client/lib/entry.js 244 bytes {0} [built] [9] ./~/sockjs-client/lib/transport-list.js 613 bytes {0} [built] [10] ./~/sockjs-client/lib/transport/websocket.js 2.71 kB {0} [built] [11] ./~/process/browser.js 2.82 kB {0} [built] [12] ./~/sockjs-client/lib/utils/event.js 2 kB {0} [built] [13] ./~/sockjs-client/lib/utils/random.js 746 bytes {0} [built] [14] ./~/sockjs-client/lib/utils/browser-crypto.js 438 bytes {0} [built] [15] ./~/sockjs-client/lib/utils/url.js 975 bytes {0} [built] [16] ./~/url-parse/index.js 8.09 kB {0} [built] [17] ./~/requires-port/index.js 753 bytes {0} [built] [18] ./~/url-parse/lolcation.js 1.58 kB {0} [built] [19] ./~/querystringify/index.js 1.3 kB {0} [built] [20] ./~/debug/browser.js 3.76 kB {0} [built] [21] ./~/debug/debug.js 4.1 kB {0} [built] [22] ./~/ms/index.js 2.33 kB {0} [built] [23] ./~/inherits/inherits_browser.js 672 bytes {0} [built] [24] ./~/sockjs-client/lib/event/emitter.js 1.27 kB {0} [built] [25] ./~/sockjs-client/lib/event/eventtarget.js 1.85 kB {0} [built] [26] ./~/sockjs-client/lib/transport/browser/websocket.js 172 bytes {0} [built] [27] ./~/sockjs-client/lib/transport/xhr-streaming.js 1.25 kB {0} [built] [28] ./~/sockjs-client/lib/transport/lib/ajax-based.js 1.31 kB {0} [built] [29] ./~/sockjs-client/lib/transport/lib/sender-receiver.js 1.15 kB {0} [built] [30] ./~/sockjs-client/lib/transport/lib/buffered-sender.js 2.3 kB {0} [built] [31] ./~/sockjs-client/lib/transport/lib/polling.js 1.32 kB {0} [built] [32] ./~/sockjs-client/lib/transport/receiver/xhr.js 1.58 kB {0} [built] [33] ./~/sockjs-client/lib/transport/sender/xhr-cors.js 343 bytes {0} [built] [34] ./~/sockjs-client/lib/transport/browser/abstract-xhr.js 4.8 kB {0} [built] [35] ./~/sockjs-client/lib/transport/sender/xhr-local.js 352 bytes {0} [built] [36] ./~/sockjs-client/lib/utils/browser.js 560 bytes {0} [built] [37] ./~/sockjs-client/lib/transport/xdr-streaming.js 984 bytes {0} [built] [38] ./~/sockjs-client/lib/transport/sender/xdr.js 2.46 kB {0} [built] [39] ./~/sockjs-client/lib/transport/eventsource.js 766 bytes {0} [built] [40] ./~/sockjs-client/lib/transport/receiver/eventsource.js 1.58 kB {0} [built] [41] ./~/sockjs-client/lib/transport/browser/eventsource.js 37 bytes {0} [built] [42] ./~/sockjs-client/lib/transport/lib/iframe-wrap.js 981 bytes {0} [built] [43] ./~/sockjs-client/lib/transport/iframe.js 3.83 kB {0} [built] [44] ./~/json3/lib/json3.js 43.3 kB {0} [built] [45] (webpack)/buildin/amd-options.js 43 bytes {0} [built] [46] ./~/sockjs-client/lib/version.js 26 bytes {0} [built] [47] ./~/sockjs-client/lib/utils/iframe.js 5.06 kB {0} [built] [48] ./~/sockjs-client/lib/utils/object.js 532 bytes {0} [built] [49] ./~/sockjs-client/lib/transport/htmlfile.js 710 bytes {0} [built] [50] ./~/sockjs-client/lib/transport/receiver/htmlfile.js 2.2 kB {0} [built] [51] ./~/sockjs-client/lib/transport/xhr-polling.js 894 bytes {0} [built] [52] ./~/sockjs-client/lib/transport/xdr-polling.js 712 bytes {0} [built] [53] ./~/sockjs-client/lib/transport/jsonp-polling.js 1.02 kB {0} [built] [54] ./~/sockjs-client/lib/transport/receiver/jsonp.js 5.57 kB {0} [built] [55] ./~/sockjs-client/lib/transport/sender/jsonp.js 2.46 kB {0} [built] [56] ./~/sockjs-client/lib/main.js 11.9 kB {0} [built] [57] ./~/sockjs-client/lib/shims.js 18.2 kB {0} [built] [58] ./~/sockjs-client/lib/utils/escape.js 2.31 kB {0} [built] [59] ./~/sockjs-client/lib/utils/transport.js 1.35 kB {0} [built] [60] ./~/sockjs-client/lib/utils/log.js 450 bytes {0} [built] [61] ./~/sockjs-client/lib/event/event.js 477 bytes {0} [built] [62] ./~/sockjs-client/lib/location.js 177 bytes {0} [built] [63] ./~/sockjs-client/lib/event/close.js 295 bytes {0} [built] [64] ./~/sockjs-client/lib/event/trans-message.js 292 bytes {0} [built] [65] ./~/sockjs-client/lib/info-receiver.js 2.22 kB {0} [built] [66] ./~/sockjs-client/lib/transport/sender/xhr-fake.js 456 bytes {0} [built] [67] ./~/sockjs-client/lib/info-iframe.js 1.52 kB {0} [built] [68] ./~/sockjs-client/lib/info-iframe-receiver.js 791 bytes {0} [built] [69] ./~/sockjs-client/lib/info-ajax.js 1.03 kB {0} [built] [70] ./~/sockjs-client/lib/iframe-bootstrap.js 2.9 kB {0} [built] [71] ./~/sockjs-client/lib/facade.js 723 bytes {0} [built] [72] ./~/strip-ansi/index.js 161 bytes {0} [built] [73] ./~/ansi-regex/index.js 135 bytes {0} [built] [74] (webpack)/hot/dev-server.js 1.85 kB {0} [built] [75] (webpack)/hot/log-apply-result.js 813 bytes {0} [built] [76] ./src/js/client.js 508 bytes {0} [built] [77] ./~/react/react.js 56 bytes {0} [built] [78] ./~/react/lib/React.js 1.49 kB {0} [built] [79] ./~/react/lib/ReactDOM.js 3.71 kB {0} [built] [80] ./~/react/lib/ReactCurrentOwner.js 653 bytes {0} [built] [81] ./~/react/lib/ReactDOMTextComponent.js 4.32 kB {0} [built] [82] ./~/react/lib/DOMChildrenOperations.js 5 kB {0} [built] [83] ./~/react/lib/Danger.js 6.96 kB {0} [built] [84] ./~/fbjs/lib/ExecutionEnvironment.js 1.09 kB {0} [built] [85] ./~/fbjs/lib/createNodesFromMarkup.js 2.71 kB {0} [built] [86] ./~/fbjs/lib/createArrayFromMixed.js 2.36 kB {0} [built] [87] ./~/fbjs/lib/toArray.js 1.98 kB {0} [built] [88] ./~/fbjs/lib/invariant.js 1.51 kB {0} [built] [89] ./~/fbjs/lib/getMarkupWrap.js 3.06 kB {0} [built] [90] ./~/fbjs/lib/emptyFunction.js 1.09 kB {0} [built] [91] ./~/react/lib/ReactMultiChildUpdateTypes.js 861 bytes {0} [built] [92] ./~/fbjs/lib/keyMirror.js 1.27 kB {0} [built] [93] ./~/react/lib/ReactPerf.js 2.51 kB {0} [built] [94] ./~/react/lib/setInnerHTML.js 3.35 kB {0} [built] [95] ./~/react/lib/setTextContent.js 1.2 kB {0} [built] [96] ./~/react/lib/escapeTextContentForBrowser.js 849 bytes {0} [built] [97] ./~/react/lib/DOMPropertyOperations.js 7.88 kB {0} [built] [98] ./~/react/lib/DOMProperty.js 9.57 kB {0} [built] [99] ./~/react/lib/quoteAttributeValueForBrowser.js 746 bytes {0} [built] [100] ./~/fbjs/lib/warning.js 1.77 kB {0} [built] [101] ./~/react/lib/ReactComponentBrowserEnvironment.js 1.26 kB {0} [built] [102] ./~/react/lib/ReactDOMIDOperations.js 3.29 kB {0} [built] [103] ./~/react/lib/ReactMount.js 36.8 kB {0} [built] [104] ./~/react/lib/ReactBrowserEventEmitter.js 12.4 kB {0} [built] [105] ./~/react/lib/EventConstants.js 2.04 kB {0} [built] [106] ./~/react/lib/EventPluginHub.js 9.22 kB {0} [built] [107] ./~/react/lib/EventPluginRegistry.js 8.41 kB {0} [built] [108] ./~/react/lib/EventPluginUtils.js 6.79 kB {0} [built] [109] ./~/react/lib/ReactErrorUtils.js 2.27 kB {0} [built] [110] ./~/react/lib/accumulateInto.js 1.74 kB {0} [built] [111] ./~/react/lib/forEachAccumulated.js 893 bytes {0} [built] [112] ./~/react/lib/ReactEventEmitterMixin.js 1.3 kB {0} [built] [113] ./~/react/lib/ViewportMetrics.js 638 bytes {0} [built] [114] ./~/react/lib/Object.assign.js 1.26 kB {0} [built] [115] ./~/react/lib/isEventSupported.js 1.97 kB {0} [built] [116] ./~/react/lib/ReactDOMFeatureFlags.js 458 bytes {0} [built] [117] ./~/react/lib/ReactElement.js 8.07 kB {0} [built] [118] ./~/react/lib/canDefineProperty.js 629 bytes {0} [built] [119] ./~/react/lib/ReactEmptyComponentRegistry.js 1.38 kB {0} [built] [120] ./~/react/lib/ReactInstanceHandles.js 10.6 kB {0} [built] [121] ./~/react/lib/ReactRootIndex.js 723 bytes {0} [built] [122] ./~/react/lib/ReactInstanceMap.js 1.25 kB {0} [built] [123] ./~/react/lib/ReactMarkupChecksum.js 1.39 kB {0} [built] [124] ./~/react/lib/adler32.js 1.2 kB {0} [built] [125] ./~/react/lib/ReactReconciler.js 3.55 kB {0} [built] [126] ./~/react/lib/ReactRef.js 2.34 kB {0} [built] [127] ./~/react/lib/ReactOwner.js 3.45 kB {0} [built] [128] ./~/react/lib/ReactUpdateQueue.js 10.9 kB {0} [built] [129] ./~/react/lib/ReactUpdates.js 8.54 kB {0} [built] [130] ./~/react/lib/CallbackQueue.js 2.44 kB {0} [built] [131] ./~/react/lib/PooledClass.js 3.55 kB {0} [built] [132] ./~/react/lib/Transaction.js 9.55 kB {0} [built] [133] ./~/fbjs/lib/emptyObject.js 482 bytes {0} [built] [134] ./~/fbjs/lib/containsNode.js 1.43 kB {0} [built] [135] ./~/fbjs/lib/isTextNode.js 628 bytes {0} [built] [136] ./~/fbjs/lib/isNode.js 712 bytes {0} [built] [137] ./~/react/lib/instantiateReactComponent.js 4.52 kB {0} [built] [138] ./~/react/lib/ReactCompositeComponent.js 27.5 kB {0} [built] [139] ./~/react/lib/ReactComponentEnvironment.js 1.67 kB {0} [built] [140] ./~/react/lib/ReactPropTypeLocations.js 549 bytes {0} [built] [141] ./~/react/lib/ReactPropTypeLocationNames.js 611 bytes {0} [built] [142] ./~/react/lib/shouldUpdateReactComponent.js 1.49 kB {0} [built] [143] ./~/react/lib/ReactEmptyComponent.js 1.8 kB {0} [built] [144] ./~/react/lib/ReactNativeComponent.js 3.02 kB {0} [built] [145] ./~/react/lib/validateDOMNesting.js 13.1 kB {0} [built] [146] ./~/react/lib/ReactDefaultInjection.js 3.99 kB {0} [built] [147] ./~/react/lib/BeforeInputEventPlugin.js 14.9 kB {0} [built] [148] ./~/react/lib/EventPropagators.js 5.22 kB {0} [built] [149] ./~/react/lib/FallbackCompositionState.js 2.49 kB {0} [built] [150] ./~/react/lib/getTextContentAccessor.js 994 bytes {0} [built] [151] ./~/react/lib/SyntheticCompositionEvent.js 1.16 kB {0} [built] [152] ./~/react/lib/SyntheticEvent.js 5.79 kB {0} [built] [153] ./~/react/lib/SyntheticInputEvent.js 1.15 kB {0} [built] [154] ./~/fbjs/lib/keyOf.js 1.11 kB {0} [built] [155] ./~/react/lib/ChangeEventPlugin.js 11.5 kB {0} [built] [156] ./~/react/lib/getEventTarget.js 930 bytes {0} [built] [157] ./~/react/lib/isTextInputElement.js 1.03 kB {0} [built] [158] ./~/react/lib/ClientReactRootIndex.js 551 bytes {0} [built] [159] ./~/react/lib/DefaultEventPluginOrder.js 1.26 kB {0} [built] [160] ./~/react/lib/EnterLeaveEventPlugin.js 3.9 kB {0} [built] [161] ./~/react/lib/SyntheticMouseEvent.js 2.2 kB {0} [built] [162] ./~/react/lib/SyntheticUIEvent.js 1.64 kB {0} [built] [163] ./~/react/lib/getEventModifierState.js 1.3 kB {0} [built] [164] ./~/react/lib/HTMLDOMPropertyConfig.js 7.63 kB {0} [built] [165] ./~/react/lib/ReactBrowserComponentMixin.js 1.15 kB {0} [built] [166] ./~/react/lib/findDOMNode.js 2.17 kB {0} [built] [167] ./~/react/lib/ReactDefaultBatchingStrategy.js 1.92 kB {0} [built] [168] ./~/react/lib/ReactDOMComponent.js 36.9 kB {0} [built] [169] ./~/react/lib/AutoFocusUtils.js 816 bytes {0} [built] [170] ./~/fbjs/lib/focusNode.js 725 bytes {0} [built] [171] ./~/react/lib/CSSPropertyOperations.js 5.71 kB {0} [built] [172] ./~/react/lib/CSSProperty.js 3.5 kB {0} [built] [173] ./~/fbjs/lib/camelizeStyleName.js 1.03 kB {0} [built] [174] ./~/fbjs/lib/camelize.js 729 bytes {0} [built] [175] ./~/react/lib/dangerousStyleValue.js 1.93 kB {0} [built] [176] ./~/fbjs/lib/hyphenateStyleName.js 1 kB {0} [built] [177] ./~/fbjs/lib/hyphenate.js 822 bytes {0} [built] [178] ./~/fbjs/lib/memoizeStringOnly.js 778 bytes {0} [built] [179] ./~/react/lib/ReactDOMButton.js 1.15 kB {0} [built] [180] ./~/react/lib/ReactDOMInput.js 5.74 kB {0} [built] [181] ./~/react/lib/LinkedValueUtils.js 5.18 kB {0} [built] [182] ./~/react/lib/ReactPropTypes.js 12.3 kB {0} [built] [183] ./~/react/lib/getIteratorFn.js 1.17 kB {0} [built] [184] ./~/react/lib/ReactDOMOption.js 2.82 kB {0} [built] [185] ./~/react/lib/ReactChildren.js 5.83 kB {0} [built] [186] ./~/react/lib/traverseAllChildren.js 6.9 kB {0} [built] [187] ./~/react/lib/ReactDOMSelect.js 6.11 kB {0} [built] [188] ./~/react/lib/ReactDOMTextarea.js 4.35 kB {0} [built] [189] ./~/react/lib/ReactMultiChild.js 14.7 kB {0} [built] [190] ./~/react/lib/ReactChildReconciler.js 4.52 kB {0} [built] [191] ./~/react/lib/flattenChildren.js 1.65 kB {0} [built] [192] ./~/fbjs/lib/shallowEqual.js 1.28 kB {0} [built] [193] ./~/react/lib/ReactEventListener.js 7.51 kB {0} [built] [194] ./~/fbjs/lib/EventListener.js 2.65 kB {0} [built] [195] ./~/fbjs/lib/getUnboundedScrollPosition.js 1.09 kB {0} [built] [196] ./~/react/lib/ReactInjection.js 1.37 kB {0} [built] [197] ./~/react/lib/ReactClass.js 27.8 kB {0} [built] [198] ./~/react/lib/ReactComponent.js 5.04 kB {0} [built] [199] ./~/react/lib/ReactNoopUpdateQueue.js 3.94 kB {0} [built] [200] ./~/react/lib/ReactReconcileTransaction.js 4.58 kB {0} [built] [201] ./~/react/lib/ReactInputSelection.js 4.32 kB {0} [built] [202] ./~/react/lib/ReactDOMSelection.js 6.83 kB {0} [built] [203] ./~/react/lib/getNodeForCharacterOffset.js 1.66 kB {0} [built] [204] ./~/fbjs/lib/getActiveElement.js 924 bytes {0} [built] [205] ./~/react/lib/SelectEventPlugin.js 6.71 kB {0} [built] [206] ./~/react/lib/ServerReactRootIndex.js 868 bytes {0} [built] [207] ./~/react/lib/SimpleEventPlugin.js 17.4 kB {0} [built] [208] ./~/react/lib/SyntheticClipboardEvent.js 1.23 kB {0} [built] [209] ./~/react/lib/SyntheticFocusEvent.js 1.12 kB {0} [built] [210] ./~/react/lib/SyntheticKeyboardEvent.js 2.76 kB {0} [built] [211] ./~/react/lib/getEventCharCode.js 1.56 kB {0} [built] [212] ./~/react/lib/getEventKey.js 2.93 kB {0} [built] [213] ./~/react/lib/SyntheticDragEvent.js 1.13 kB {0} [built] [214] ./~/react/lib/SyntheticTouchEvent.js 1.33 kB {0} [built] [215] ./~/react/lib/SyntheticWheelEvent.js 1.99 kB {0} [built] [216] ./~/react/lib/SVGDOMPropertyConfig.js 3.8 kB {0} [built] [217] ./~/react/lib/ReactDefaultPerf.js 8.63 kB {0} [built] [218] ./~/react/lib/ReactDefaultPerfAnalysis.js 5.79 kB {0} [built] [219] ./~/fbjs/lib/performanceNow.js 844 bytes {0} [built] [220] ./~/fbjs/lib/performance.js 612 bytes {0} [built] [221] ./~/react/lib/ReactVersion.js 379 bytes {0} [built] [222] ./~/react/lib/renderSubtreeIntoContainer.js 463 bytes {0} [built] [223] ./~/react/lib/ReactDOMServer.js 766 bytes {0} [built] [224] ./~/react/lib/ReactServerRendering.js 3.3 kB {0} [built] [225] ./~/react/lib/ReactServerBatchingStrategy.js 673 bytes {0} [built] [226] ./~/react/lib/ReactServerRenderingTransaction.js 2.3 kB {0} [built] [227] ./~/react/lib/ReactIsomorphic.js 2.05 kB {0} [built] [228] ./~/react/lib/ReactDOMFactories.js 3.36 kB {0} [built] [229] ./~/react/lib/ReactElementValidator.js 10.8 kB {0} [built] [230] ./~/fbjs/lib/mapObject.js 1.47 kB {0} [built] [231] ./~/react/lib/onlyChild.js 1.21 kB {0} [built] [232] ./~/react/lib/deprecated.js 1.77 kB {0} [built] [233] ./~/react-dom/index.js 63 bytes {0} [built] [234] ./src/js/components/Layout.js 2.84 kB {0} [built] [235] ./src/js/components/Footer.js 2.33 kB {0} [built] [236] ./src/js/components/Header.js 2.35 kB {0} [built] [237] ./src/js/components/Header/Title.js 2.32 kB {0} [built] webpack: bundle is now VALID. </code></pre>
2
Python filter doesn't work as expected
<p>I have the following Python code:</p> <pre><code>a = [1,2,3,'4','55',6] filter(int,a) </code></pre> <p>The output is:</p> <pre><code>[1, 2, 3, '4', '55', 6] </code></pre> <p><code>filter()</code> is supposed to remove the elements from the provided sequence which translate into false, and return only those elements which translate into true. </p> <p>I expected the output to be:</p> <pre><code>[1,2,3,6] </code></pre> <p>since these are the only integers in my list. Am I missing something essential? </p>
2
How to create help buttons in Android?
<p>I currently have a homescreen with three buttons. I would like to add a small button on the side of each button that when clicked would pop up a some sort of pop-up, that would explain the functionality of each button. Is there a built-in function for this? Or is this more like a tool-tip? Thank you</p>
2
How to set Primary Key and Foreign key in Redis
<p>I have created two hash key value pair in <strong>Redis</strong> named <code>Person</code> and <code>Account</code>. The <code>Person</code> key has the first name and last name of the person and the <code>Account</code> Key contains account type and savings. Now I want to do a join similar to SQL joins(<code>inner join</code>) to retrieve the account type and savings of each person from both the hash values.</p> <p>Kindly help me out to find a solution to this problem and could anyone please help me in setting a primary key and foreign key in Redis hash key value pairs.</p>
2
How to find when a matrix converges with a loop
<p>I've been given a matrix:</p> <pre><code>P &lt;- matrix(c(0, 0, 0, 0.5, 0, 0.5, 0.1, 0.1, 0, 0.4, 0, 0.4, 0, 0.2, 0.2, 0.3, 0, 0.3, 0, 0, 0.3, 0.5, 0, 0.2, 0, 0, 0, 0.4, 0.6, 0, 0, 0, 0, 0, 0.4, 0.6), nrow = 6, ncol = 6, byrow = TRUE) </code></pre> <p>Using the functions, <code>mpow</code>, <code>rows_equal</code>, <code>matrices_equal</code>. I want to find when <code>P^n</code> converges, in other words what n is, when all the rows are equal in the matrix and when <code>P^n = P^(n+1)</code>.</p> <p>By just looking at the functions <code>i</code> have managed to deduce that around <code>n=19-21</code> the matrix will converge. </p> <p>Although, I want to find the right n using a loop. Here under are the functions <code>mpow</code>, <code>rows_equal</code> and <code>matrices_equal</code>. I know they can be written differently but please keep them as they are. </p> <pre><code>mpow &lt;- function(P, n, d=4) { if (n == 0) diag(nrow(P))) else if (n== 1) P else P %*% mpow(P, n - 1)) } rows_equal &lt;- function(P, d = 4) { P_new &lt;- trunc(P * 10^d) for (k in 2:nrow(P_new)) { if (!all(P_new[1, ] == P_new[k, ])) { return(FALSE)} } return(TRUE) } matrices_equal &lt;- function(A, B, d = 4) { A_new &lt;- trunc(A * 10^d) B_new &lt;-trunc(B * 10^d) if (all(A_new == B_new)) TRUE else FALSE } </code></pre> <p>Now, to write the loop, we should do it something along the lines of:</p> <p>First creating a function like so:</p> <pre><code>when_converged &lt;- function(P) {...} </code></pre> <p>and </p> <pre><code>for (n in 1:50) </code></pre> <p>To try for when t.ex n = 50. </p> <p>Although i don't know how to write the code correctly to do so, can anyone help me with that? </p> <p>Thank you for reading my question.</p>
2
xdata and ydata must be the same length
<p>I am trying to get my plot of temperature data to update by replacing the past 10 iterations with the next 10 as seen in the code before but I keep getting a "xdata and ydata must be the same length" error. Along with fixing the error, is this the best way to do such a task of replacing a certain amount of old data with new data on a real time plot? Note: there is a little more code in the file but it is just for opening and reading the labjack equipment</p> <pre><code>temperature = [] x = list() y = list() x1 = list() y1 = list() # Read loop for i in range(60): # Get the thermocouple reading on AIN0. tempC = ljm.eReadName(handle, "AIN0_EF_READ_A") temperature.append(tempC) dT = temperature[i]-temperature[i-1] if -.5&lt;dT&lt;.5: print "Temperature:","%.3f"% temperature[i]," " "dT:", "%.3f"% dT, " " "Steady State" sleep(1) else: print "Temperature:","%.3f"% temperature[i]," " "dT:", "%.3f"% dT sleep(1) x.append(i) y.append(temperature[i]) x1.append(i) y1.append(dT) fig = plt.figure() ax = fig.add_subplot(111) li, = ax.plot(x,y) # draw and show it fig.canvas.draw() plt.show(block=False) # loop to update the data while True: try: y[:-10] = y[10:] y.append(temperature[i]) # set the new data li.set_ydata(y) fig.canvas.draw() sleep(1) except KeyboardInterrupt: break # Close handle ljm.close(handle) </code></pre>
2
Safari(iOS): Embed YouTube Video Always Plays In Low Quality
<p>I need to play YouTube Videos with at least 720p resolution on my mobile tv web app, but safari plays them always with the lowest quality, that sucks. </p> <p>I tried a lot of solutions that have been already posted, but they seem to be outdated. e.g. <code>&amp;vq=hd720</code>, <code>&amp;hd=1</code>, <code>&amp;vq=hd1080</code> appending to the embed iframe, unfortunately it's not working.</p> <p>I also tried to do it with the youtube javascript api, what a surprise, no luck either. </p> <p>Any other solutions I could try? The Videos are uploaded in portrait format 720x1280.</p>
2
Call PowerShell script from VBScript but windows close
<p>This VBScript runs a few PowerShell scripts. I put the invocation of <code>notepad.exe</code> there to make sure it ran as an admin.</p> <p>My PowerShell scripts open consoles but then they close immediately.<br> I would like to have them stay open.</p> <p>What is wrong? </p> <p>Here is my VBScript:</p> <pre><code>RunAsAdmin() Set shell = WScript.CreateObject("WScript.shell") shell.Run("powershell.exe -noexit -executionpolicy bypass -file .\Source\RemoveWindows10Apps-2.0.ps1"), 1 , True Set shell = WScript.CreateObject("WScript.shell") shell.Run("powershell.exe -noexit -executionpolicy bypass -file .\Source\ChangeWin10StartLayout.ps1"), 1 , True Set shell = WScript.CreateObject("WScript.shell") shell.Run("powershell.exe -noexit -executionpolicy bypass -file .\Source\NewFolder.ps1"), 1 , True Set shell = WScript.CreateObject("WScript.shell") shell.Run("notepad.exe"), 1 , True Function RunAsAdmin() Dim objAPP If WScript.Arguments.length = 0 Then Set objAPP = CreateObject("Shell.Application") objAPP.ShellExecute "wscript.exe", """" &amp; _ WScript.ScriptFullName &amp; """" &amp; " RunAsAdministrator",,"runas", 1 WScript.Quit End If End Function </code></pre>
2
Gulp and absolute path
<p>I am new in Gulp. I was wondering if I could have an absolute path for source like the code below:</p> <pre><code>var gulp = require('gulp'); var concat = require('gulp-concat'); var minify = require('gulp-minify-css'); gulp.task('hello', function() { return gulp.src(['C:\a\b\c\css\fonts.css', 'C:\a\b\c\css\common.css', 'C:\a\b\c\css\generic.css']) .pipe(concat('stylestest.css')) .pipe(minify()) .pipe(gulp.dest('web')); }); </code></pre> <p>If not, is it possible to put gulp project and web application next to each other, instead of putting web application inside the gulp project directory. Actually, I don't want to change current structure of my project but I see people copy app inside gulp project folder.</p>
2
Python udp performance
<p>I am setting up a pretty simple message server using TCP and UDP on different ports on a Raspberry PI 2 with wifi. I am using UDP for multi-cast. The server works fine. The problem is that the processor jumps to about 30% processor usage when I run the server (TCP and UDP listeners). This isn't processing anything, just listening. When I shut down the UDP it goes to about 3-5%. Is this normal (it is a RPi), or am I doing something wrong? Here is the code for initializing the UDP listener:</p> <pre><code>class UDPServer(asyncore.dispatcher): def __init__(self): asyncore.dispatcher.__init__(self) multicast_group = '224.3.29.71' server_address = ('', 8081) # Create the socket self.create_socket(socket.AF_INET, socket.SOCK_DGRAM) # Bind to the server address self.bind(server_address) group = socket.inet_aton(multicast_group) mreq = struct.pack('4sL', group, socket.INADDR_ANY) self.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP, mreq) print("UDP listening on {}:{}".format(multicast_group,8081)) </code></pre>
2
how Do I structure/compile my ruby project
<p>im brand new to Ruby and I just finished coding a program.</p> <p>the program has about 350 lines of code, 6 methods but no classes. it uses constants and global variables.</p> <p>Is it convention to, for example, have the global variables/constants in a seperate file? should I split all the methods into different files?</p> <p>What should the folders be like where I have all the files?</p> <p>and Lastly, how do i create a makefile (or rakefile whatever it's called. i have the rake rubygem)</p> <p>thank you very much</p>
2
"Changes are not allowed while code is running"
<p>I am constantly going back and forth between my code in Visual Studio 2015 and my browser. When I forget to turn off the debugger before trying to make edits I get this error:</p> <blockquote> <p>Changes are not allowed while code is running.</p> </blockquote> <p>It comes with an annoying bleep sound and a popup. Is there a way to make that go away and have Visual Studio simply stop my code automatically when it clearly sees I am trying to make edits?</p> <p>It's normally fine, I simply click ok, manually stop my code and then try the edits again. The problem is when I am on a stubborn piece of code that doesn't want to work and I am going back and forth I sometimes forget to stop the code. At that point I am frustrated already because of the code and then to get this stupid popup with a bleep sound is enough to send me into a rage of cursing.</p>
2
What is safe method to perform `Object.assign` when using AngularJS?
<p>Basically I would like to perform <code>Object.assign</code> to get copy of my data, without anything that AngularJS attached in the past, it attaches now, or may attach in future versions.</p> <p>Sure I can delete such property as <code>$$hashKey</code> after assignment but this approach is totally fragile, on the other hand I could manually construct the object with fields I want but this on the other hand is tiresome (and also fragile if I change definition of my source object).</p> <p>Is there something solid in between?</p>
2
Read from SQL Server Reporting Services with C#
<p>My company has lots of SQL Reports located at <code>http://server/ReportServer</code> and I want to make a WinForms app to read from them on a periodic schedule and do stuff with the information.</p> <p>I've done some research with this and found this page: <a href="https://msdn.microsoft.com/en-us/library/ms155362.aspx" rel="nofollow">https://msdn.microsoft.com/en-us/library/ms155362.aspx</a> but I'm still not sure how to get started. Any tips?</p>
2
Easiest Method for determining Active Directory groups and members in SQL
<p>I need to write a report in SSRS (T-SQL) that shows any current user which reports on the SSRS report server they have read-access to, which is determined by Active Directory at the present. To complicate matters, the Active Directory doesn't have groups set up as group elements - all users in the AD are objectClass=User and objectCategory=Person.</p> <p>My question is: how can I write a query that will match a user to all their "memberOf" elements without knowing necessarily what the group names are (since they might change, etc.)? From there, I think I can piece together how to match each element to the reports.</p> <p>EDIT: Here's what I have written so far. It's not creating the procedure because of a syntax error, but I can't spot the error.</p> <pre><code>USE [ReportServer] GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE PROCEDURE [dbo].[ActiveDirectoryPermissions] AS BEGIN SET NOCOUNT ON; DECLARE @Table1 TABLE ( [GroupName] nvarchar(MAX), [GroupPath] nvarchar(MAX) ) INSERT INTO @Table1 ( [GroupName], [GroupPath] ) SELECT sAMAccountName as [GroupName], replace(ADsPath,'LDAP://','') as [GroupPath] FROM OPENQUERY( ADSI, 'SELECT sAMAccountname, ADsPath FROM ''LDAP://DC=[REDACTED],DC=COM'' WHERE objectCategory=''group'' AND CN=''*'' ORDER BY CN') DECLARE @Table2 TABLE ( [GroupPath] nvarchar(MAX), [MemberName] nvarchar(MAX) ) DECLARE table_1_cursor CURSOR FOR SELECT GroupPath FROM @Table1 t1 DECLARE @SQL nvarchar(MAX) DECLARE @temp nvarchar(MAX) OPEN table_1_cursor FETCH NEXT FROM table_1_cursor INTO @temp WHILE @@FETCH_STATUS = 0 BEGIN SET @SQL = 'SELECT '''+@temp+''' AS GroupPath, cn FROM OPENQUERY(ADSI, ''SELECT cn FROM ''''LDAP://DC=[REDACTED],DC=com'''' WHERE memberOf='''''+@temp+''''' '')' INSERT INTO @Table2 ( [GroupPath], [MemberName] ) EXEC sp_executesql @SQL; FETCH NEXT FROM table_1_cursor INTO @temp END CLOSE table_1_cursor DEALLOCATE table_1_cursor SELECT * FROM @Table2 t2 INNER JOIN @Table1 t1 ON (t2.GroupPath=t1.GroupPath) GO </code></pre>
2
Declaring Multiple Variables of different types in JavaScript
<p>When declaring multiple variables in JavaScript, what are the data type restrictions?</p> <pre><code>var name = "John", letter = 'J', pi = 3.14, hasCar = true, license = [6,8,2,7,9,1,5], car = {type:"Fiat", model:"500", color:"white"}; </code></pre> <p>A similar question was asked, but doesn't provide a full answer:</p> <p><a href="https://stackoverflow.com/questions/694102/declaring-multiple-variables-in-javascript">Declaring Multiple Variables in JavaScript</a></p>
2
UTF to ASCII Conversion
<p>I am using Java web service to call an oracle procedure to read some records. The executing of this Java web service is automated with the help of Shell Script. So the flow is like:</p> <p>Shell scripts calls the Java Web service, further Java web service calls the Oracle stored procedure to read some records.</p> <p>As an end product a feed file is generated which is in UTF-8 format and we need our file to be created in ASCII. So could any one help me with some Linux or Java code which I could add to my shell script or Java code to convert the file to ASCII.</p> <p>P.S. I am aware about converting the file from UTF to ASCII with help of NOTEPAD++, but i need this process to be automated. Any help would be highly appreciated. </p>
2
Add object using ng-model
<p>I have a form which updates values on submit like this</p> <pre><code>&lt;form ng-submit="updateMovie()"&gt; &lt;input type="text" ng-model="movie.title"/&gt; &lt;input type="text" ng-model="movie.rating"/&gt; //what to attach here at ng-model// &lt;input type="text" ng-modal ="movie.__"/&gt; there could be many genre inputs based on how many user wants to input &lt;/form&gt; </code></pre> <p>The object submitted by the form will be of the following type. For the moment lets <strong><em>ignore the ids</em></strong>. I dont know how can I create the genre i.e. <strong><em>Array of objects</em></strong></p> <pre><code>"id": 4792, "title": "Insidious", "rating": "7.0", "genres": [ { "id": 3, "name": "horror" }, { "id": 7, "name": "Drama" } ] </code></pre>
2
Get the most recent file
<p>Using</p> <pre><code>DirectoryStream&lt;Path&gt; stream = Files.newDirectoryStream(dir,pattern); </code></pre> <p>I get a <code>DirectoryStream</code> of files in my <code>dir</code> which match <code>pattern</code>. But I'm not interested in all those files. I only want to get the most recent one and I know that the filename of the most recent one is the largest filename in terms of lexicographical order (because the timestamp is included). What is the easiest way to get this file? Is it always the one which comes last in my stream? What would you do?</p>
2
get Height Value from NSLayoutConstraint
<p>In my project I am using AutoLayOut, There is one UIView which is subView main View, I have set its width(using constrains) equal to 2 :3 superView's width and its height equal to its View. I need view to be circular shape so I am setting its cornerRadius to heightOfView/2. There is 1:1 aspect ration of views's height and width. I have created Outlet of that constrain as </p> <pre><code> @IBOutlet weak var circleHeight: NSLayoutConstraint </code></pre> <p>Now I want to acces its Height or Width but I m not gwtting actual value,</p> <pre><code>circleHeight.firstItem.frame.width </code></pre> <p>I am getting value which I have stored from Storyboard, There Is something I am Missing but could not figured it out</p> <p><a href="https://i.stack.imgur.com/fG1FL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fG1FL.png" alt="enter image description here"></a> Selected View should be circular. but when i print its constain's values it gives height and width as 214 only</p>
2
Downloading and Installing IPA from server if user clicks on button on Iphone
<p>I am working on an app where I deploy the .ipa file and manifest.plist on my server and from there I try to install the app to my iphone. </p> <p>The app is initially installed but I need to check if a latest version is available on the server. I have done this part and now wish to install the latest .ipa from the server directly to my phone without redirecting user to the html page of the server</p> <p>Found some links on stack overflow, especially this: <a href="https://stackoverflow.com/questions/23561370/download-and-install-an-ipa-from-url-on-ios">Download and install an ipa from url on iOS</a> I have done this:</p> <pre><code> let endPointURL = NSURL(string: "itms-services://?action=download-manifest&amp;url=myUrlString") UIApplication.sharedApplication().openURL(endPointURL!) </code></pre> <p>I get unsupported URL exception. Can anyone tell me how I can achieve this? Is there any other way to directly start installing the upgrade without navigating to the actual html page?</p>
2
How to display only SEI VUI Frames using ffmpeg or ffprobe tools or any other standard tool?
<p>I tried ffprobe -show_format -show_streams -show_frames input_video , but this is not displaying exact sei vui frames information like their frame number length etc. what command can be used for the same</p>
2
[Laravel 5.1]Custom routes display a white (blank) page
<p>Im currently using XAMPP (PHP 5.6.21) on a Win 10 machine.</p> <p>Im doing a migration from a site in .net to laravel. Until now i almost had no problem, most of the previous problems came from inexperience. But i can't find solutions for this error.</p> <p><strong><em>routes.php</em></strong></p> <pre><code>//Operaciones Route::resource('operaciones', 'OperacionesController'); //Ruta al cierre de Operaciones Route::any('operaciones/cerrar', ['as' =&gt; 'operaciones/cerrar', function(){ dd('asdasd'); }]); </code></pre> <p>The resource route works fine, but the 2nd route brings me a white (blank) page</p> <p>And does not matter if i put anything in the web browser</p> <p>if i put</p> <pre><code>http://localhost:8080/mutualv0/public/operaciones/asdasdasd </code></pre> <p>white page, if i put</p> <pre><code>http://localhost:8080/mutualv0/public/operaciones/cerrar </code></pre> <p>withe again...</p> <p>But, if y try this</p> <pre><code>http://localhost:8080/mutualv0/public/operaciones2 </code></pre> <p>NotFoundHttpException</p> <p>I have nothing in the logs, i installed a laravel link checker and does not trow me any errors... i just don´t know what to do... </p> <p><strong>UPDATE</strong></p> <p>I tried</p> <pre><code>php artisan route:cache </code></pre> <p>It brought me an error <em>"unable to prepare route [operaciones/cerrar] for serialization. uses closure"</em> </p> <p>SO i change the route to this</p> <pre><code>Route::get('operaciones/cerrar', ['as' =&gt; 'operaciones/cerrar', 'uses' =&gt; 'OperacionesController@cerrar']); </code></pre> <p>And add a function to OperacionesController</p> <pre><code>public function cerrar() { dd('hello'); } </code></pre> <p>I used <em>php artisan serve</em> but still having the same error... withe (blank) page...</p> <p><strong>UPDATE 2</strong></p> <p>The link i use is</p> <pre><code>&lt;a href="{{ route('operaciones/cerrar') }}" class="btn btn-success" role="button"&gt;Cerrar operaciones seleccionadas&lt;/a&gt; </code></pre> <p>I tried to change the link to</p> <pre><code>&lt;a href="{{ route('cerraroperaciones') }}" class="btn btn-success" role="button"&gt;Cerrar operaciones seleccionadas&lt;/a&gt; </code></pre> <p>And update the route to</p> <pre><code>Route::any('operaciones/cerrar', [ 'as' =&gt; 'cerraroperaciones', 'uses' =&gt; ' OperacionesController@cerrar' ]); </code></pre> <p>But it throws me a <em>Route [cerraroperaciones] not defined</em></p> <p>I also tried to do a <em>link_to_action</em>, and throws me an "action not defined" at OperacionesController@cerrar</p> <p><strong>UPDATE 3</strong></p> <p>Uploaded to GitHub </p> <p><a href="https://github.com/diegorosano/mutual" rel="nofollow">https://github.com/diegorosano/mutual</a></p>
2