kernel

-3

votes
2

answer
25

views

Random Number Generation in C# errors out

So i am trying to generate a random number and if the number is 3 or 8 i what something to happen , it this case to add 1 to one of the 2 integers keep in mind i really am only going off a book in C# and some knowledge in VB int Number1 = 0; int Number12 = 0; string text; string text2; Exexs: Rando...
Kernel
-2

votes
0

answer
26

views

Python script runs from home directory

I have a pyinstaller executable (pyinstaller -F script.py) and .db file. Both in /home/dev/dist directory. This script can't find .db file despite it locates in the same directory. I figured out that script always runs from /home directory. How to change path from /home to actually dir where the scr...
Kernel Panic
1

votes
2

answer
373

views

How do Chef and Docker work together

I am trying to migrate my applications from Heroku to AWS, and I want to use Chef/Docker on AWS. I may need several servers to do the migration for web server, app server, db, redis... I want my deployment flow to be as simple as heroku; and I want to minimize the configuration of the servers on AWS...
ming.kernel
1

votes
3

answer
4.5k

views

unity raycast , on raycast leave , how to ? c#

i have a problem understanding how to keep a reference to an object that has previously been hit by a raycast . for example i can have a raycast script put on the camera of my 1rst person controller going from the camera position to the forwad vector * some value this script is attached to the came...
Line Kernel
2

votes
2

answer
3.3k

views

@Media print css

I have my HTML page with this structure: .... navigation menu My div to display in print mode ....content.... .... HTML elements If a user tries to print the page, I want only the content of the DIV with class to-print to be printed. How can I achieve that?
Kernel Med
1

votes
4

answer
727

views

Multithreading issue while using Mutex in SerialCommunication C++

I am developing a serial communication software using windows functions. In this CSerialCommhelper is class which handles all the serial communication functions and CphysicalLayer is one which make use of that class. class CSerialCommHelper : public CCommAgent { HANDLE m_pPortHandle; //Han...
kernel
5

votes
4

answer
2.1k

views

Why do I get a segmentation fault while iterating through this string?

I'm trying to implement a basic shift cipher in C++. I can't move forward until I figure out what's causing the segmentation fault. I stepped through the code using gdb and the problem seems to stem from the iterator. 1 #include 2 #include 3 4 std::string encrypt (std::string plain, int key); 5...
the_kernel
1

votes
1

answer
74

views

Why do i get a segmentation fault (core dumped) in the program below when i use N=1023 instead of 1024?

Below is a simple program to plot a 2D gaussian, for N=1022 and below the program works fine, but for N=1023 and higher i get Segmentation error(core dumped), am i missing something? I have not used pointers anywhere, except for writing the data file #include #include void main() { int i, j; int N;...
kernel_panic
5

votes
1

answer
396

views

help in understanding this code snippet

This is code snipper from header.S file in kernel code. I could not understand what the lretw instruction does. I've checked out so many online sources for the instruction. # We will have entered with %cs = %ds+0x20, normalize %cs so # it is on par with the other segments. pushw %ds pushw $6f...
kernel_os
4

votes
3

answer
731

views

Regex to match each subdomain of a URL

I'm trying to write a Regex that extracts the subdomain/domain parts of a URL as separate strings. I've tried this: /^[^:]+:\/\/([^\.\/]+)(\.[^\.\/]+)+(?:\/|$)/ It should work against these URLs: http;//www.mail.yahoo.co.uk/blah/blah http;//test.test.again.mail.yahoo.com/blah/blah I want to break it...
Kernel James
5

votes
5

answer
613

views

Where is the default parameter in Python function

I think many people have seen the python's function which receives default parameters. For example: def foo(a=[]): a.append(3) return a If we call this function using foo(), the output will append integer '3' each time after the call. When this function is defined, a function object named 'foo' is d...
ming.kernel
2

votes
3

answer
173

views

searching in vim editor

this is a simple query about the searching in vim editor. consider that i searched for a string like "str" with /str now after this search i wanted to search for "strcat" like /strcat but, the point in here is that i dont want to type entire /str again.... just wanted to add the new text to /str....
kernel_os
2

votes
3

answer
571

views

Java regex - alphanumeric, at most one hyphen, period or underscore, seven characters long

I'm new to the regex tool in Java, and despite their great potential I'm having a hard time accomplishing this task. I want to write a regex to validate an input string which respects the following syntax: any combination of lowercase letters and digits only one underscore, one dash or one period (...
kernel_panic
1

votes
3

answer
106

views

Without quotations, OnClick function is calling automatically

The script I wrote has a button that, when clicked, should show year and IP address, but it does automatically. I saw in another 3D that this issue comes when in the "onclick" option you put a function like AH-AH but this is not my case. AH-AH function myFunction(json) { var d = new Date(); var n =...
Kernel
1

votes
1

answer
1.1k

views

Set Octopus parameter from PowerShell script

I'm working with Octopus and I need to add in one of my PowerShell scripts the chance to modify an Octopus Parameter (not Variable...). In few words, my website deploys in 2 folders, alternately, and I have to take a trace of this. My idea is to set a parameter that, at every run of the script reads...
Kernel
2

votes
1

answer
1.9k

views

How to use Unix Socket to communicate between ruby and Python

I am trying to do some communication between my ruby process and Python process; and I want to use UNIX socket. Objective: ruby process "fork and exec" the Python process. In ruby process, create a UNIX socket pair, and pass it to Python. Ruby code (p.rb): require 'socket' r_socket, p_socket = Socke...
ming.kernel
4

votes
3

answer
417

views

What's the difference between expression and statement using Python yield [duplicate]

Possible Duplicate: Expression Versus Statement What's the difference between expression and statement in Python? I have never thought of this question until I am learning Python generator that said "use yield as an expression" Also, can you explain this question in the context of Python generator...
ming.kernel
2

votes
1

answer
346

views

rails asset precompile error when less-rails

I was doing rake assets:precompile and found this error: rake aborted! error evaluating function asset-url: method `method_missing' called on terminated object (0x007fe94f714518 flags=0x0 klass=0x0) (in /Users/huming/work/strikingly/Bobcat/app/assets/stylesheets/themes/bright/main.less) at less.Pars...
ming.kernel
3

votes
4

answer
847

views

Memory leaks and other resources after a process dies

Suppose a program has memory leaks. 1) When a process dies (normally or segmentation fault), are those leaked memory freed? 2) What about other resources a process holds?
ming.kernel
3

votes
4

answer
5.1k

views

C# String.Format optional parameters

i want to use string.Format with optional parameters : public static void Main(string[] args) { //Your code goes here // Console.WriteLine(string.Format("{0} {1}", "a", "b")); Console.WriteLine(string.Format("{0} {1}", "a")); } for exemple the parameter {1} to be optional and to have a default valu...
Kernel Med
5

votes
2

answer
2.8k

views

How to test an ES7 async function using mocha/chai/chai-as-promised

I have the following function to test: // ... const local = new WeakMap(); export default class User { // ... async password(password) { if (!password) return local.get(this).get('hash'); // remove this for security reasons! if (password.length < 6) throw new Error('New password must be at least 6 c...
kernel
2

votes
1

answer
721

views

How to detect the camera disconnection in linux?

How will you detect the camera signal disconnection (not the module disconnection or hardware disconnection) without the support of V4l2-ctl command? Because my Camera Driver is not supporting v4l2-ctl command.
Kernel
2

votes
3

answer
2k

views

Get path+filename of file that was opened with my application

I'm an amateur at c# and I've been unable to locate the answer to this. Perhaps I am not aware of the correct terms to use. When a video file is dragged onto my exe application, I would like the application to know that it was launched with a file and be able to know the path and filename of that fi...
Quantum_Kernel
2

votes
2

answer
52

views

Access properties of objects in an object

I have 3 classes MetaA, MetaB and MetaC. Each have a number of properties. There are certain situations where it would be nice to just have one class that contains the properties of all three Meta classes, called for example, MetaComposite. In the composite class, I have tried creating and instance...
Quantum_Kernel
2

votes
1

answer
628

views

git update submodule via windows batch file

I wrote a small batch file which updates the git submodules. My only problem is I want to review the changes after the git command but the command window closes - even if I add the "pause" command to it. See: @echo off git submodule foreach git pull origin master pause When I replace the whole git c...
kernel
4

votes
2

answer
202

views

C# hamming encoded serial output

I'm trying to talk to a RS232 device that expects hamming encoded ASCII characters. The following table is provided by the manufacturer: Byte Encoded 0 15 1 02 2 49 3 5E 4 64 5 73 6 38 7 2F 8 D0 9 C7 A 8C B 9B C A1 D...
Quantum_Kernel
7

votes
2

answer
4.2k

views

Nginx $request_uri has duplicated query parameter

I found that nginx's $request_uri duplicate the query parameters. To goal I want to achieve is to redirect any request of naked domain to www domain. Here is a sample configuration. server { listen 8080; server_name localhost; location / { if ($http_host !~* "^www\.") { rewrite (.*) http:...
ming.kernel
3

votes
1

answer
892

views

Deleting variable does not erase its memory from RAM memory

I am using Python (Canopy) extensively for Earth science application. Because my application is memory consuming, I am trying find way to erase variable that I don't need any more in my programs, I tried to use del command to erase the variable memory, but I found that space used by Canopy is still...
kernel
2

votes
1

answer
416

views

The difference of mruby and embedding Python in C program

In mruby, we can embed the ruby code in a C program. We can also do this in Python. Is there any difference in the principle of these two?
ming.kernel
4

votes
2

answer
69

views

Create an immutable subclass of ArrayList

I'm designing a simple class subclassing ArrayList. In my application's context, this list acts as a 'reference list', returning Color objects following a circular and well-defined order. @SuppressWarnings("serial") public final class ColorList extends ArrayList { private static int colorIndex = -1;...
kernel_panic
2

votes
1

answer
118

views

How to distribute several python process in a distributed environment

I have serval python processes talk to each other via socket; each process has a specific role or function. These processes are initially running on a wire LAN (and the ip of the machines are static ), so I assign an ip address and port number for each one of them to let them find each other and ta...
ming.kernel
6

votes
1

answer
1.3k

views

Difference between runtime dynamic binding and class inheritance

I am trying to clarify the concept of runtime dynamic binding and class inheritance in dynamic languages (Python, ruby) and static type languages (java, C++). I am not sure I am right or not. In dynamic languages like Python and Ruby, runtime dynamic binding is implemented as duck typing. When the i...
ming.kernel
2

votes
1

answer
90

views

Best way to program in C++ remotely through an vps via FTP/SSH

For years, I had been using Notepad++ with nppFTP plugin for coding, which works amazing, it uploads them fastly by just pressing Alt+S, I also need to compile the code after the upload, I use PuTTY to achieve it via cli, I quickly swap windows and type clear && make && ./app(using up arrow to enter...
Mc Kernel
4

votes
2

answer
1.3k

views

What's a distributed lock and why use it?

Why do people need a distributed lock? When the shared resource is protected by it's local machine, does this mean that we do not need a distributed lock? I mean when the shared resource is exposed to others by using some kind of api or service, and this api or service is protected using it's loca...
ming.kernel
2

votes
0

answer
340

views

Python parallel programming “No traceback available"

I am trying to run parallel code in python utilizing ipyparallel package. import ipyparallel as ipp # create client & view rc = ipp.Client() dv = rc[:] v = rc.load_balanced_view() def my(i): import numpy as np aa[:,:,i]=np.dot(uanom_L[:,:,i-I_a:i+I_a+1],lcoz_a) bb[:,:,i]=np.dot(uanom_L[:,:,i-I_...
kernel
2

votes
1

answer
545

views

fb like button not showing on any browser except chrome

I've used the iframe code to display the fb like button on a site I am developing, usually it turns out right for all browser but this on only display on chrome. I tried using html5 and xfbml still doesn't show on other browsers. Tried fixing height and width on the css span on the html5 version st...
KerneL
2

votes
1

answer
12k

views

jQuery dynamic image loading

**I try to load an image when I type a reference in an input. $(document).ready(function () { $('#id').focus(); $('#id').keyup(function () { $('#img').html(''); $('#img').hide().fadeIn('slow'); }); }); The fadeIn() doesn't work, except if the image is already in cache. How can I have a fadeIn each t...
Kernel
3

votes
2

answer
1.8k

views

Typecasting or accessing char array to integer array in Python

I have a char array in Python, which is read from a file e.g. char_array = [0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f] how do i convert/typecast/access this to an array of integers like int_array[0] = 0x03020100 int_array[1] = 0x07060504 int_array...
Kernel Ninja
3

votes
4

answer
363

views

Write an XML element as <element/> instead of <element></element> if the InnerText is null

I am writing a c# class to write an XML file that needs to exactly match the structure of an existing XML we use so that some legacy systems dont get confused. When the InnerText value of an element is null, I need the element markup of the xml element to be like instead of I managed to do it by acc...
Quantum_Kernel
3

votes
3

answer
650

views

program life in terms of paged segmentation memory

I have a confusing notion about the process of segmentation & paging in x86 linux machines. Will be glad if some clarify all the steps involved from the start to the end. x86 uses paged segmentation memory technique for memory management. Can any one please explain what happens from the moment an ex...
kernel_os

View additional