Skip to content

Instantly share code, notes, and snippets.

@jaseg
jaseg / gist:3e0c29b635f969ab46cd
Created September 28, 2014 11:51
Number of global variables in the ZSH source tree
newton~/d/z/Src <3 egrep -in 'mod_export.*;' **.c|wc -l
191
/*
* Copyright (c) 1997-2006 Motoyuki Kasahara
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
@jaseg
jaseg / luapy.py
Created January 9, 2015 01:02
How to run some lua from python via ctypes
import ctypes as ct
lua = ct.CDLL('liblua.so.5.2')
lua.luaL_newstate.restype = ct.c_void_p
lua.lua_tolstring.restype = ct.c_char_p
st = lua.luaL_newstate()
def foo(st):
print(lua.lua_tolstring(st, 1, 0).value.decode())
@jaseg
jaseg / test.c
Created January 9, 2015 01:06
Extremely simple ctypes example
// compile with $ gcc -o test.so -shared test.c
int fnord(int a, int b){
return a+4*b-1;
}
@jaseg
jaseg / bcsucks.sh
Last active August 29, 2015 14:13
gnu bc flakiness
newton~ <3 bc -l
bc 1.06.95
Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'.
# thanks to matti for this
*1
(standard_in) 1: syntax error
*1
1
xkb_symbols "mixed" {
include "pc+jp(OADG109A)+inet(evdev)+level3(ralt_switch)+level3(lalt_switch)"
key <CAPS> { [ Escape , Eisu_toggle ] };
key <AE05> { [ 5 , percent , EuroSign ] };
key <AE11> { [ minus , equal , dead_macron ] };
key <AE12> { [ asciicircum , asciitilde , dead_circumflex ] };
key <AE13> { [ yen , bar , underscore ] };
key <AD01> { [ q , Q , adiaeresis , Adiaeresis ] };
#include <unistd.h>
#include <sys/prctl.h>
#include <stdlib.h>
#include <signal.h>
void hup_handler(int signal){
exit(0);
}
int main(int argc, char **argv){
set showtabline=never
set go-=r
set defsearch=duckduckgo
com! search-selection,ss -bang -nargs=? -complete search -js commands.execute((bang ? "open " : "tabopen " ) + args + " " + buffer.currentWord)
map <A-s> :set nss!=<A-Tab>
map <A-C-s> :set nst!=<A-Tab>
#include <stdio.h>
main(argc, argv)
int argc;
char **argv;
{
printf("Hello world\n");
}
#!/Hello world!