Skip to content

Instantly share code, notes, and snippets.

$ whois getcoupons.pw
Domain ID:CNIC-DO2751397
Domain Name:GETCOUPONS.PW
Created On:2014-05-20T18:54:45.0Z
Last Updated On:2014-05-25T18:57:08.0Z
Expiration Date:2015-05-20T23:59:59.0Z
Status:clientTransferProhibited
Status:serverTransferProhibited
Registrant ID:L24FVEUTOVCIHDJM
Registrant Name:WhoisGuard Protected
@ikai
ikai / subprocess_cmd_args.py
Created August 6, 2015 20:13
Shows how to print the exact string subprocess is using from a list
cmd_args = ['cat', 'somefile.txt']
print subprocess.list2cmdline(cmd_args)
require 'java'
require File.dirname(__FILE__) + '/commons-codec-1.3.jar'
require File.dirname(__FILE__) + '/commons-httpclient-3.1.jar'
require 'cgi'
module JRestClient
include_package 'org.apache.commons.httpclient'
include_package 'org.apache.commons.httpclient.methods'
include_package 'org.apache.commons.httpclient.params'
/*
Corresponding table:
CREATE TABLE `users` (
`id` int(11) NOT NULL auto_increment,
`name` varchar(255) default NULL,
`admin` tinyint(1) default '0',
PRIMARY KEY (`id`)
)
/*
JDO Persistence Manager in Scala using blocks
Sample below works with Google App Engine
Sample usage:
Persistence.manage { (pm) =>
val message = new Message("message body here")
pm.makePersistent(message)
var anchors = document.getElementsByTagName("a");
for(var i = 0; i < anchors.length; i++) {
var a = anchors[i];
var href = a.getAttribute("href");
// for some reason the HREF in this onClick is always bound to the last element in anchors[]. WHY?!
a.onclick = function(el) {
//console.log(href);
import org.mortbay.jetty.Server
import org.mortbay.jetty.servlet.Context
import org.mortbay.jetty.servlet.ServletHolder;
object Main {
def main(args: Array[String]) {
var server = new Server(8080)
println("Starting world server")
private byte[] getByteArrayFromInputStream(InputStream stream) throws IOException {
byte[] bytes;
int len;
byte[] buffer = new byte[8192];
ByteArrayOutputStream output = new ByteArrayOutputStream();
try {
while ((len = stream.read(buffer, 0, buffer.length)) != -1) output.write(buffer, 0, len);
bytes = output.toByteArray();
} finally {
@ikai
ikai / 100_line_js_func.js
Created October 24, 2012 21:56
100 line JavaScript function
function longFunction() {
var x = 1;
x = 0;
x = 1;
x = 2;
x = 3;
x = 4;
x = 5;
x = 6;
x = 7;
@ikai
ikai / slack_example.py
Created October 7, 2015 18:51
Actual working slack example code
from slackclient import SlackClient
# Don't prefix the #
channel_name = 'apitest'
# Your API key is actually found at https://api.slack.com/web
token = 'your API key'
sc = SlackClient(token)
sc.rtm_connect()