Skip to content

Instantly share code, notes, and snippets.

@NeoCat
NeoCat / 2048.stp
Last active Aug 29, 2015
2048 -- Join the numbers and get to the 2048 tile using SystemTap!
View 2048.stp
#!/bin/bash
//usr/bin/env stty -echo; sudo staprun -T 30 `stap -p4 "$0"` "$@"; stty echo; exit
// 2048.stp - written by NeoCat
// Inspired by https://github.com/gabrielecirulli/2048/
// Licensed under MIT license or GPLv2
// Join the numbers and get to the 2048 tile!
// HOW TO PLAY: Use your arrow keys to move the tiles. When two tiles with the same number touch, they merge into one!
@NeoCat
NeoCat / ignchild.c
Last active Aug 29, 2015
Avoid zombie processes on Linux
View ignchild.c
/*
* Avoid creation of zombie process by child processes.
* build: gcc -O2 ignchld.c -o ignchld
* usage: ignchld bad-command-that-creates-zombie-processes [args ...]
*/
#include <signal.h>
#include <string.h>
#include <unistd.h>
@NeoCat
NeoCat / ideone.pl
Last active Aug 29, 2015
Submit a source code in the specified language to ideone.com (in private mode) and get executed results
View ideone.pl
#!/usr/bin/perl
use strict;
use warnings;
use SOAP::Lite;
my $user = '******';
my $pass = '******';
my $client = SOAP::Lite->new(proxy => 'http://ideone.com/api/1/service');
@NeoCat
NeoCat / add2numbers_12lang_polyglot
Created Apr 21, 2014
12 language polyglot which adds 2 numbers from stdin. Runnable in Bash/Brainf**k/C/CLIPS/INTERCAL/Perl/Perl 6/Python/Ruby/Pike/Prolog (swi)/Whitespace, tested in Ideone.com http://ideone.com/JmXx4l .
View add2numbers_12lang_polyglot
#define x /* ++[>[-]+>>++++++++++[>++++++[>++++++<-]>++<<<<[[-]>+>>>>,----------<<<<<]>[<+>-]>>>>[>+>+<<-]<[>>-<<-]>>>>+<[[-]>-<]>[[-]<<[+]<<<<<<[-]>>[-]+<<>>>>>>>>]>>>>>>>>>>[>+<-]<[>+<-]<[>+<-]<[>+<-]<[>+<-]<[>+<-]<[>+<-]<[>+<-]<[>+<-]<<<<[>>>>+<<<<-]<<<<-]<<<[>>+>+<<<-]>>[<<+>>-]>-[[-]>>>>>>>+++++++++[>>>>>>>>>>>>>>>>>>>>[>+<-]<[>+<-]<[>+<-]<[>+<-]<[>+<-]<[>+<-]<[>+<-]<[>+<-]<[>+<-]<[>+<-]<[>+<-]<[>+<-]<[>+<-]<[>+<-]<[>+<-]<[>+<-]<[>+<-]<[>+<-]<[>+<-]<<-]<<<<<<<]<<<-]>>>>>>>>>>>>>>>>>>>>[>>>>>>>>>+<<<<<<<<<-]<[>>>>>>>>>+<<<<<<<<<-]<[>>>>>>>>>+<<<<<<<<<-]<[>>>>>>>>>+<<<<<<<<<-]<[>>>>>>>>>+<<<<<<<<<-]<[>>>>>>>>>+<<<<<<<<<-]<[>>>>>>>>>+<<<<<<<<<-]<[>>>>>>>>>+<<<<<<<<<-]<[>>>>>>>>>+<<<<<<<<<-]<++++++++[>>>>>>>>>>[<<<<<<<<+<+>>>>>>>>>-]<<<<<<<<[>>>>>>>>+<<<<<<<<-]+++++++++[<[[<<+>>-]<<->>]<<[>>+<<-]>>>-]<[[-]>>>>>>>>>---------->+<<<<<<<<<<][<+>-]>[<+>-]>[<+>-]>[<+>-]>[<+>-]>[<+>-]>[<+>-]>[<+>-]>[<+>-]>[<+>-]>[<+>-]>[<+>-]>[<+>-]>[<+>-]>[<+>-]>[<+>-]>[<+>-]>[<+>-]><<<<<<<<<<<<<<<<<<<-]>>>>>>>>>>>>+++++++++[<<[[-
@NeoCat
NeoCat / tweet-ingress-damage.rb
Last active Aug 29, 2015
Monitor your GMail mail box and tweet the damage report.
View tweet-ingress-damage.rb
#!/usr/bin/ruby
require 'net/imap'
require 'nokogiri'
require 'twitter'
require 'cgi'
require 'open-uri'
mail_user = '***@gmail.com'
mail_password = '***'
mail_label = 'Ingress'
@NeoCat
NeoCat / gist:a6189f245347581d608c
Created Jan 20, 2015
twicli CSS - Don't enlarge thumbnails on hover & enlarge thumbnails when selected
View gist:a6189f245347581d608c
/* twicliの設定→ユーザスタイルシートに下記をペーストして保存 */
/* サムネールをマウスオーバーで拡大しない */
.thumbnail-image:hover { max-width: 32px; width: 32px\9; }
/* tweetをクリックで選択した時にサムネールを拡大 */
div.selected img.thumbnail-image { width: auto; max-width: 300px; }
@NeoCat
NeoCat / test-pib-iser.sh
Created Apr 1, 2015
Test tgtd iSER connection via pib (tested in Fedora 21)
View test-pib-iser.sh
#!/bin/sh
IB_ADDR=172.24.100.1
TARGET_IQN=iqn.2015-05.com.example:test
if [ $EUID -ne 0 ]; then
sudo "$0" "$@"
exit $?
fi
View gist:576290
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <oauth.h>
int main(int argc, char **argv)
{
char *consumer_key = "*********************";
char *consumer_secret = "******************************************";
char *access_token = "********-*****************************************";
View variadic-template-fizzbuzz-c++0x.cpp
#include <iostream>
using namespace std;
namespace vtstring {
// 文字列を表す可変引数テンプレート
template <char... a> struct vtstring;
template <char a, char... b>
struct vtstring<a, b...>
{
View oauth-sign-url.rb
require 'oauth'
request = OAuth::RequestProxy.proxy(
"method" => 'GET',
"uri" => 'https://betastream.twitter.com/2b/user.json',
"parameters" => {
"oauth_consumer_key" => "******************",
"oauth_token" => "***-******************",
"oauth_nonce" => OAuth::Helper.generate_key,
"oauth_timestamp" => OAuth::Helper.generate_timestamp,