This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float InvSqrt(float x){ | |
float xhalf = 0.5f * x; | |
int i = *(int*)&x; // store floating-point bits in integer | |
i = 0x5f3759d5 - (i >> 1); // initial guess for Newton's method | |
x = *(float*)&i; // convert new bits into float | |
x = x*(1.5f - xhalf*x*x); // One round of Newton's method | |
return x; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import static java.util.Arrays.*; | |
import static java.lang.Math.*; | |
import java.io.*; | |
import java.lang.*; | |
import java.util.*; | |
class main112 { | |
private int[] A, C; | |
private int N; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var nodeio = require('node.io'); | |
var options = { | |
benchmark: false, | |
timeout: 999, //Timeout after 10 seconds | |
max: 1, //Run xx threads concurrently (when run() is async) | |
retries: 5, //Threads can retry x times before failing | |
auto_retry: false | |
}; | |
exports.job = new nodeio.Job(options, { | |
init: function() { }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This grid shows the restaurants in Hamburg which have E la Carte units ("Prestos") installed in | |
them. The Ps in the grid represent restaurants with Prestos installed ("Prestorants"). Os | |
represent restaurants without prestos. | |
Alyssa P. Hacker from the E la Carte ops team wants to count the number of restaurants in the | |
largest contiguous rectangular block of Prestorants. What is the number that she comes up with? | |
Answer: __44__ | |
top-left corner: (15, 5742) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ http://altdevblogaday.com/2011/08/06/demise-low-level-programmer/ | |
Floating Point Numbers | |
They are very useful but often used in situations where they simply don’t suit the solution the programmer is attempting to write. The following links should provide some background and info on where they are not so useful, what the pitfalls are and sometimes even how to avoid them. | |
http://www.cprogramming.com/tutorial.html#fptutorial | |
http://www.johndcook.com/blog/2009/04/06/numbers-are-a-leaky-abstraction/ | |
http://www.codeproject.com/KB/recipes/float_point.aspx | |
http://drdobbs.com/184402741?pgno=4 | |
http://users.tkk.fi/jhi/infnan.html |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# a look at strings and methods | |
# tested with Python23 vegaseat 23jan2005 | |
print "Fill an empty string:" | |
empty_string = "" | |
for k in range(65, 91): | |
empty_string += chr(k) | |
print empty_string | |
print "\nOriginal string (California humor):" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
# dmn001 <at> gmail | |
# 31/01/2011 | |
my %pos; | |
my %neg; | |
my $num_lines = <STDIN>; | |
while (<STDIN>){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
""" | |
Amar Pai ([email protected]) | |
Solution to Dropbox challenge - Packing Your Dropbox | |
http://www.dropbox.com/jobs/challenges#packing-your-dropbox | |
I've had this problem on the brain and have been unable to | |
stop thinking about it, so I finally hacked out a rudimentary |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Netragard’s Hacker Interface Device (HID). Category: Hardware, Healthcare, | |
penetration test, Realistic Threat, Research, Software, Total Infrastructure | |
Compromise / Tag: Adrian Crenshaw, Healthcare, malware, Mouse, Netragard, | |
penetration test, Prion, Teensy, USB / Add Comment Author: Adriel Desautels We | |
(Netragard) recently completed an engagement for a client with a rather restricted | |
scope. The scope included a single IP address bound to a firewall that offered no | |
services what so ever. It also excluded the use of social attack vectors based on | |
social networks, telephone, or email and disallowed any physical access to the | |
campus and surrounding areas. With all of these limitations in place, we were | |
tasked with penetrating into the network from the perspective of a remote threat, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
How to use Google Charts API with 6 examples | |
Few months ago I had a good look into Google Charts API and it was great! If you are not aware, Google Charts API basically allows you to create pretty graphs simply by using an URL with correct parameters specified. It is fairly flexible, with many things you can change and customise - which is where it becomes bit complicated. It is quite easy to generate a chart, but it wasn't as easy to generate the exact chart I needed. So below are 6 examples charts with explanations and tips that will hopefully help you understand Google Charts better. | |
A few notes before I start | |
The data/labels for all the graphs here have no meaning at all - just examples that I have come up with. | |
I'll explain each parameter probably only once (since they are generally the same across all graphs). If something is different or special I'll explain it again. | |
If you have any other tips/hints please share |