Skip to content

Instantly share code, notes, and snippets.

View ayourtch's full-sized avatar
💭
hacking some Rust

Andrew Yourtchenko ayourtch

💭
hacking some Rust
View GitHub Profile
function default_page(page, req, resp, params)
local form = {
{ "text", name = "textfield", id = "stTagInput", autocomplete = "off", class = "input-text",
value = params.test, title = "this is a text" },
{ "submit", value = "set", class = "input-btn" },
method = "post", action = "post", id = "UpdateForm"
}
page.myform = form
-- http://lua-users.org/lists/lua-l/2002-04/msg00180.html
require 'socket'
local header =
[[HTTP/1.1 200 OK
Date: Fri, 19 Apr 2002 20:37:57 GMT
Server: Apache/1.3.23 (Darwin) mod_ssl/2.8.7 OpenSSL/0.9.6b
Cache-Control: max-age=60
Expires: Fri, 19 Apr 2002 20:38:57 GMT
diff --git a/Makefile b/Makefile
index 2d269fe..07ee2e9 100644
--- a/Makefile
+++ b/Makefile
@@ -107,4 +107,4 @@ sqlite3:
cd $(SQLITE3_DIR) && $(MAKE)
zeromq:
- cd $(ZEROMQ_DIR) && $(MAKE)
+ cd $(ZEROMQ_DIR) && ./configure --prefix=$(PREFIX) && $(MAKE)
@ayourtch
ayourtch / gist:752460
Created December 23, 2010 02:19
Programming Challange from Erann Gat
-- Andrew Yourtchenko - Programming Challange from Erann Gat:
-- http://www.flownet.com/ron/papers/lisp-java/
-- Given a list of words and a list of phone numbers, find all the ways that
-- each phone number can be expressed as a list of words.
-- No batteries included. We have to define our own split() function.
function string:split(sep)
local sep, fields = sep or ":", {}
local pattern = string.format("([^%s]+)", sep)
self:gsub(pattern, function(c) fields[#fields+1] = c end)
@ayourtch
ayourtch / gist:761926
Created January 1, 2011 19:07
Print stack trace with hex addresses
void bt() {
enum { BT_SIZE = 10 }; // Whatever big enough.
int i;
void *btbuf[BT_SIZE];
int btsize = backtrace(btbuf, BT_SIZE);
printf("Backtrace entries: %d\n", btsize);
for(i=0; i<btsize; i++) {
printf("%d: %p\n", i, btbuf[i]);
}
}
@ayourtch
ayourtch / gist:762039
Created January 1, 2011 21:56
checking malloc
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
void checkzero(char *p, int size) {
while(--size) {
if(p[size]) {
printf("%p is non-zero at offset %d, the value is 0x%02hhx\n",
p, size, p[size]);
ctrl-z
bg
touch /tmp/stdout
touch /tmp/stderr
gdb -p $!
# In GDB
p dup2(open("/tmp/stdout", 1), 1)
p dup2(open("/tmp/stderr", 1), 2)
@ayourtch
ayourtch / test-gai.c
Created January 20, 2011 17:24
getaddrinfo one-family test
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <netdb.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <pthread.h>
@ayourtch
ayourtch / emoji.pl
Created December 18, 2013 13:50 — forked from windytan/emoji.pl
# Oona Räisänen 2013
@emoji = qw( 🌀 🌂 🌅 🌈 🌙 🌞 🌟 🌠 🌰 🌱 🌲 🌳 🌴 🌵 🌷 🌸
🌹 🌺 🌻 🌼 🌽 🌾 🌿 🍀 🍁 🍂 🍃 🍄 🍅 🍆 🍇 🍈
🍉 🍊 🍋 🍌 🍍 🍎 🍏 🍐 🍑 🍒 🍓 🍔 🍕 🍖 🍗 🍘
🍜 🍝 🍞 🍟 🍠 🍡 🍢 🍣 🍤 🍥 🍦 🍧 🍨 🍩 🍪 🍫
🍬 🍭 🍮 🍯 🍰 🍱 🍲 🍳 🍴 🍵 🍶 🍷 🍸 🍹 🍺 🍻
🍼 🎀 🎁 🎂 🎃 🎄 🎅 🎈 🎉 🎊 🎋 🎌 🎍 🎎 🎏 🎒
🎓 🎠 🎡 🎢 🎣 🎤 🎥 🎦 🎧 🎨 🎩 🎪 🎫 🎬 🎭 🎮
🎯 🎰 🎱 🎲 🎳 🎴 🎵 🎷 🎸 🎹 🎺 🎻 🎽 🎾 🎿 🏀

Keybase proof

I hereby claim:

  • I am ayourtch on github.
  • I am ayourtch (https://keybase.io/ayourtch) on keybase.
  • I have a public key whose fingerprint is 53D8 1901 106A 392C 2D40 9F00 163C C42D 427C 2DBC

To claim this, I am signing this object: