Skip to content

Instantly share code, notes, and snippets.

View sureshg's full-sized avatar
🚀
☕️

Suresh sureshg

🚀
☕️
View GitHub Profile
@indy
indy / improved-perlin-noise.java
Created February 6, 2010 12:22
Perlin noise - Java implementation
// JAVA REFERENCE IMPLEMENTATION OF IMPROVED NOISE - COPYRIGHT 2002 KEN PERLIN.
public final class ImprovedNoise {
static public double noise(double x, double y, double z) {
int X = (int)Math.floor(x) & 255, // FIND UNIT CUBE THAT
Y = (int)Math.floor(y) & 255, // CONTAINS POINT.
Z = (int)Math.floor(z) & 255;
x -= Math.floor(x); // FIND RELATIVE X,Y,Z
y -= Math.floor(y); // OF POINT IN CUBE.
z -= Math.floor(z);
@zaius
zaius / background.sh
Created January 16, 2011 23:29
How to redirect a running process output to a file and log out
ctrl-z
bg
touch /tmp/stdout
touch /tmp/stderr
gdb -p $!
# In GDB
p dup2(open("/tmp/stdout", 1), 1)
p dup2(open("/tmp/stderr", 1), 2)
@joelgwebber
joelgwebber / fetch_natgeo_2011.py
Created December 21, 2011 06:43
Quick python hack to fetch the desktop versions of all the National Geographic 2011 Photo Contest winners and editors' picks
import urlparse
from urllib import urlretrieve
base_url = 'http://ngm.nationalgeographic.com/'
urls = [ \
"/u/H6yMi6fUB_1JR964xxG8RxsYArlNNn1lR5PWutchJ4t_YnYgRQSgSbjtWe2l0Iy-oLGsA9CsqdnrlLhmR0g3rCSzBRF7/", \
"/u/H6yMi6fUB_1JR964xxG8RxsYArlNNn1lR5PWutchJ4t_Y-BNZaUHGX3GhRGQkkys1pZ0r6MMH1tkBqLFL_pSFt3xA3Oi/", \
"/u/H6yMi6fUB_1JR964xxG8RxsYArlNNn1lR5PWutchJ4t6VV_HIvlh3DLvd9e4D4G0uBFWsZpxfwWu_TJ9TchpFQyt2qg8/", \
"/u/H6yMi6fUB_1JR964xxG8RxsYArlNNn1lR5PWutchJ4rkKJOkhh6J27Lg1KkOxF6sBxFqALR33By8KpJ5CndmMknK8Yyx/", \
package com.koushikdutta.nio;
import java.nio.ByteBuffer;
import java.nio.channels.ReadableByteChannel;
import java.util.LinkedList;
import junit.framework.Assert;
public class ByteBufferList {
private static final String LOGTAG = "Tether";
@mostlygeek
mostlygeek / demo.rb
Created January 24, 2012 21:29
Chef ruby_block and dynamic resource creation
ruby_block "sync_build_from_s3" do
action :nothing
block do
# latest_file contains path to the latest.txt, which lists files to sync
file = File.new(latest_file, "r");
run_context = Chef::RunContext.new(node, {})
#
# Create the directory to hold the new build files
#
@jboner
jboner / latency.txt
Last active July 22, 2024 14:44
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@chitan
chitan / WsChatServlet.java
Created July 7, 2012 01:44
How to use WebSocket of Tomcat
//This sample is how to use websocket of Tomcat.
package wsapp;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.util.ArrayList;
import org.apache.catalina.websocket.MessageInbound;
import org.apache.catalina.websocket.StreamInbound;
import org.apache.catalina.websocket.WebSocketServlet;
@danparsons
danparsons / gist:3195652
Created July 29, 2012 01:46
How to stream the London 2012 Olympics

How to stream the London 2012 Olympics

There have been several HOWTOs posted regarding streaming the 2012 Olympics using HTTP / SOCKS proxies via SSH and other similar methods. None of these actually work using the latest Flash on Mountain Lion (with Firefox, Chrome or Safari). Additionally, the third-party streaming sites don't provide BBC's amazing interface, which lets you quickly skip to individual competitors and events. However, setting up an OpenVPN server does work, with some tweaks. You'll get the exact same UX that people in England receive.

@romannurik
romannurik / CheatSheet.java
Last active May 16, 2023 13:42
Android helper class for showing cheat sheets (tooltips) for icon-only UI elements on long-press. This is already default platform behavior for icon-only action bar items and tabs. This class provides this behavior for any other such UI element.
/*
* Copyright 2012 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@Nurdok
Nurdok / python_conversion.md
Last active July 11, 2024 15:00
Python Conversion

Python Number Conversion Chart

From To Expression