Skip to content

Instantly share code, notes, and snippets.

@NeoCat
NeoCat / 2048.stp
Last active August 29, 2015 13:58
2048 -- Join the numbers and get to the 2048 tile using SystemTap!
#!/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 August 29, 2015 13:58
Avoid zombie processes on Linux
/*
* 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 August 29, 2015 14:00
Submit a source code in the specified language to ideone.com (in private mode) and get executed results
#!/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 April 21, 2014 14:47
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 .
#define x /* ++[>[-]+>>++++++++++[>++++++[>++++++<-]>++<<<<[[-]>+>>>>,----------<<<<<]>[<+>-]>>>>[>+>+<<-]<[>>-<<-]>>>>+<[[-]>-<]>[[-]<<[+]<<<<<<[-]>>[-]+<<>>>>>>>>]>>>>>>>>>>[>+<-]<[>+<-]<[>+<-]<[>+<-]<[>+<-]<[>+<-]<[>+<-]<[>+<-]<[>+<-]<<<<[>>>>+<<<<-]<<<<-]<<<[>>+>+<<<-]>>[<<+>>-]>-[[-]>>>>>>>+++++++++[>>>>>>>>>>>>>>>>>>>>[>+<-]<[>+<-]<[>+<-]<[>+<-]<[>+<-]<[>+<-]<[>+<-]<[>+<-]<[>+<-]<[>+<-]<[>+<-]<[>+<-]<[>+<-]<[>+<-]<[>+<-]<[>+<-]<[>+<-]<[>+<-]<[>+<-]<<-]<<<<<<<]<<<-]>>>>>>>>>>>>>>>>>>>>[>>>>>>>>>+<<<<<<<<<-]<[>>>>>>>>>+<<<<<<<<<-]<[>>>>>>>>>+<<<<<<<<<-]<[>>>>>>>>>+<<<<<<<<<-]<[>>>>>>>>>+<<<<<<<<<-]<[>>>>>>>>>+<<<<<<<<<-]<[>>>>>>>>>+<<<<<<<<<-]<[>>>>>>>>>+<<<<<<<<<-]<[>>>>>>>>>+<<<<<<<<<-]<++++++++[>>>>>>>>>>[<<<<<<<<+<+>>>>>>>>>-]<<<<<<<<[>>>>>>>>+<<<<<<<<-]+++++++++[<[[<<+>>-]<<->>]<<[>>+<<-]>>>-]<[[-]>>>>>>>>>---------->+<<<<<<<<<<][<+>-]>[<+>-]>[<+>-]>[<+>-]>[<+>-]>[<+>-]>[<+>-]>[<+>-]>[<+>-]>[<+>-]>[<+>-]>[<+>-]>[<+>-]>[<+>-]>[<+>-]>[<+>-]>[<+>-]>[<+>-]><<<<<<<<<<<<<<<<<<<-]>>>>>>>>>>>>+++++++++[<<[[-
@NeoCat
NeoCat / tweet-ingress-damage.rb
Last active August 29, 2015 14:05
Monitor your GMail mail box and tweet the damage report.
#!/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 January 20, 2015 22:50
twicli CSS - Don't enlarge thumbnails on hover & enlarge thumbnails when selected
/* 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 April 1, 2015 19:40
Test tgtd iSER connection via pib (tested in Fedora 21)
#!/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
#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 = "********-*****************************************";
#include <iostream>
using namespace std;
namespace vtstring {
// 文字列を表す可変引数テンプレート
template <char... a> struct vtstring;
template <char a, char... b>
struct vtstring<a, b...>
{
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,