Skip to content

Instantly share code, notes, and snippets.

View pyk's full-sized avatar
🐈‍⬛
I may be slow to respond.

pyk pyk

🐈‍⬛
I may be slow to respond.
View GitHub Profile
@pyk
pyk / file.go
Last active August 29, 2015 14:27
golang "cannot assign to" http://play.golang.org/p/GJWp1G8H-E
package main
import (
"fmt"
)
type A struct {
name string
s []string
}
@pyk
pyk / kmp.c
Last active August 29, 2015 14:27
Knuth–Morris–Pratt algorithm in C https://en.wikipedia.org/wiki/Knuth–Morris–Pratt_algorithm
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void create_failure_fn(char *p, int lenp, int table[]);
int search_kmp(char *s, int lens, char *p, int lenp, int table[]);
int
main()
{
@pyk
pyk / adams-heroku-values.md
Last active August 29, 2015 14:27 — forked from adamwiggins/adams-heroku-values.md
My Heroku values

Make it real

Ideas are cheap. Make a prototype, sketch a CLI session, draw a wireframe. Discuss around concrete examples, not hand-waving abstractions. Don't say you did something, provide a URL that proves it.

Ship it

Nothing is real until it's being used by a real user. This doesn't mean you make a prototype in the morning and blog about it in the evening. It means you find one person you believe your product will help and try to get them to use it.

Do it with style

@font-face {
font-family: "Proxima Nova";
src: url(data:font/opentype;base64,d09GRgABAAAAAEywABIAAAAAg3QAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABEWU5BAAAGbAAAALgAAAGJNI0oHkZGVE0AAAGUAAAAHAAAABxdnq2WR0RFRgAAByQAAAA4AAAAQgSqBTxHUE9TAAAHXAAABCIAABH0zI0AF09TLzIAAAXUAAAAVwAAAGCAz3p9Y21hcAAASvgAAAG2AAAC5lCJVL9jdnQgAAABsAAAAB4AAAAeCkcLCmZwZ20AAAHQAAABsgAAAmUjtC+nZ2FzcAAAA4QAAAAIAAAACAAAABBnbHlmAAALgAAAO4sAAF8I3FzIU2hlYWQAAAOMAAAANQAAADb9TDtqaGhlYQAABiwAAAAgAAAAJA9PBsBobXR4AABHDAAAAh8AAANsqw8hfGxvY2EAAEksAAABuAAAAbhtqYQ8bWF4cAAABkwAAAAgAAAAIAIDAhpuYW1lAAADxAAAAawAAANRLIw+gnBvc3QAAErkAAAAEwAAACD/DQAocHJlcAAABXAAAABjAAAAdNUcAaMAAAABAAAAAMmJbzEAAAAAyRrF1wAAAADK+niN/pAAAAPGBTYBYADCANABNgE+AWgBmQDkAZIBkAFYAAB42l1Ru05bQRDdDQ+TBBJjg+RoU8xmQhrvhYYCJBBXF8XIdmM5QtqNXORiXMAHUCBRg/ZrBmgoKdKmQcgFUj6BT0BiZk2iKM3Ozuycc+bMknKk6l1a73nqnARSuNOg2abfDql2FuCedH21kZF28EDzzYxeuW7ff8VgM5pyRw2gvOct5SGjaSdQi/bU/za/guE+/2Qeg0FLM01PrZOQHkJgvhm3MPie0ay7/KQvWB0uBgNDimkq7vJzKuV/S3Outgibaxm9dnAmIj+ZBmhqpY1A0186pHo+jmIJctkw1gYTU9afZCL4ZjJd1VQtM751cJfszDt
@pyk
pyk / .indent.pro
Last active December 15, 2015 11:07
This is a list of options that will be used by indent(1) to formatting the C source code.
/* indent(1) Profile
* This is a list of options that will be used by indent(1) to formatting the
* C source code.
*
* For complete available options
* https://www.gnu.org/software/indent/manual/html_section/indent_15.html#SEC17
*
* Copyright 2015 Bayu Aldi Yansyah <[email protected]>
*
* Licensed under the Apache License, Version 2.0 (the "License");
/* Alternative version of https://github.com/antirez/redis/blob/3.2/src/server.c#L3651-L3666 */
void usage(void) {
fprintf(stderr,
"Usage: ./redis-server [/path/to/redis.conf] [options]\n"
" ./redis-server - (read config from stdin)\n"
" ./redis-server -v or --version\n"
" ./redis-server -h or --help\n"
" ./redis-server --test-memory <megabytes>\n\n"
"Examples:\n"
" ./redis-server (run the server with default conf)\n"
@pyk
pyk / echoserver.go
Created January 21, 2016 03:16
echoserver - A simple TCP echo server written in Go
// echoserver - A simple TCP echo server written in Go
//
// Build:
// % go build echoserver.go
//
// Usage:
// % ./echoserver 8080
//
// License:
// BSD 3-clause Revised
@pyk
pyk / README.md
Last active September 18, 2019 17:53
Install Oracle java 8 on debian jessie

Run

wget https://gist.githubusercontent.com/pyk/19a619b0763d6de06786/raw/b09ce3a6626484adb5339597dfd391d0db9fe3cb/install-oracle-java-8-on-debian-jessie.sh
sh install-oracle-java-8-on-debian-jessie.sh

See the following blog post

@pyk
pyk / roulette.java
Last active October 22, 2017 08:27
Roulette-wheel selection via stochastic acceptance. More on http://arxiv.org/abs/1109.3627 https://en.wikipedia.org/wiki/Fitness_proportionate_selection
public class roulette {
public static void main(String [] args) {
int n=4;
double [] weight = new double [n];
weight[0]=0.4;
weight[1]=0.3;
weight[2]=1.2;
weight[3]=0.1;
double max_weight=1.2;
int [] counter = new int[n];
@pyk
pyk / note.sh
Created June 18, 2016 19:12
new way to install llvm libc++ in Ubuntu 14.04 Trusty
# http://llvm.org/apt/
sudo bash -c "cat >> /etc/apt/sources.list" << LLVMAPT
# LLVM
deb http://llvm.org/apt/trusty/ llvm-toolchain-trusty main
deb-src http://llvm.org/apt/trusty/ llvm-toolchain-trusty main
# 3.5
deb http://llvm.org/apt/trusty/ llvm-toolchain-trusty-3.5 main
deb-src http://llvm.org/apt/trusty/ llvm-toolchain-trusty-3.5 main
# 3.6