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: