Skip to content

Instantly share code, notes, and snippets.

View Xe's full-sized avatar
😂
h

Xe Iaso Xe

😂
h
View GitHub Profile
@omeid
omeid / express.go
Last active August 29, 2015 14:09
Node.js (Express) Style Go Middleware in 40 line of code.
package main
import (
"log"
"net/http"
"time"
)
type Handler func(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)
class LinkedList {
private class Node {
public char data;
public Node next;
Node(char d, Node n) {
data = d;
next = n;
}
}
@bjtitus
bjtitus / Perl SafeConnect Bypass
Created January 25, 2011 16:46
SafeConnect Bypass
#!/usr/bin/perl
use Net::Ping;
$host = "www.google.com";
while (1) {
$p = Net::Ping->new('icmp');
if ($p->ping($host)) {
print "$host is alive.\n";
@acous
acous / dark-compact.css
Last active March 28, 2016 19:15
early dark theme for Shout irc
body {
background: #333;
color: #CCC;
font: 16px Lato, sans-serif;
margin: 0;
}
#main {
background: #222;
border-radius: 0px;
bottom: 0px;

Displaying images in the terminal with tput and echo

output

Requires ImageMagick, easily available from your favorite package manager. Tested on Linux and OSX
convert image.png -resize 40 txt:-|sed -E 's/://;s/\( ? ?//;s/, ? ?/,/g;s/\)//;s/([0-9]+,[0-9]+,[0-9]+),[0-9]+/\1/g;s/255/254/g;/mage/d'|awk '{print $1,$2}'|sed -E 's/^0,[0-9]+ /print "echo;tput setaf "\;/;s/^[0-9]+,[0-9]+ /print "tput setaf ";/;s/(.+),(.+),(.+)/\1\/42.5*36+\2\/42.5*6+\3\/42.5+16/'|bc|sed 's/$/;echo -n "  ";/'|tr '\n' ' '|sed 's/^/tput rev;/;s/; /;/g;s/$/tput sgr0;echo/'|bash
@geoffb
geoffb / simple_websocket_client.html
Created October 7, 2010 23:37
Super simple websockets client/server using Python. Compatible with the draft 76 challenge/response.
<!DOCTYPE html>
<html lang="en">
<head>
<title>WebSocket Client</title>
<style>
#output {
border: solid 1px #000;
}
</style>
</head>
@andyshinn
andyshinn / DEISGCE.md
Last active June 7, 2020 19:17
Deis in Google Compute Engine

Deis in Google Compute Engine

Let's build a Deis cluster in Google's Compute Engine!

Google

Get a few Google things squared away so we can provison VM instances.

Google Cloud SDK

@jonhoo
jonhoo / README.md
Last active July 19, 2021 10:49
Distributed RWMutex in Go
@jsound
jsound / GarbageOnly_GarbageProducer
Created December 23, 2013 13:38
A simple GC micro benchmark that creates only objects of 0 lifetime (but as many of them as possible)
package de.am.gc.benchmarks;
/**
* A GC micro benchmark running a given number of threads that create objects of a given size and dereference them immediately
*
* @author jsound
*/
public class GarbageOnly {
// object size in bytes
private static final int DEFAULT_NUMBEROFTHREADS=8;
@mumrah
mumrah / websocketserver.py
Created August 7, 2010 17:01
Simple WebSockets in Python
import time
import struct
import socket
import hashlib
import sys
from select import select
import re
import logging
from threading import Thread
import signal