Skip to content

Instantly share code, notes, and snippets.

View samuell's full-sized avatar
💻
Hacking away

Samuel Lampa samuell

💻
Hacking away
View GitHub Profile
@samuell
samuell / addposts.php
Created November 1, 2015 15:25
ProcessWire template for a REST API endpoint that creates pages from POST requests
<?
$title = $_POST['title'];
$timestamp = $_POST['timestamp'];
$body = $_POST['bodytext'];
function div( $txt ) {
echo '<div>' . $txt . '</div>';
}
echo div($title) . div($timestamp) . div($body);
@samuell
samuell / multiprocessing_queue_test.py
Created September 21, 2015 20:16
multiprocessing_queue_test.py
import multiprocessing as mproc
# ------------------------------------------------------------------
def lower(qin, qout):
while True:
s = qin.get()
if s is None:
#print 'Exiting %s ...' % mproc.current_process().name
qin.task_done()
@samuell
samuell / dataflow_syntax_example.go
Last active August 29, 2015 14:25
Code example showing the Go version of the final python example code in the bottom of this post: http://bionics.it/posts/fbp-data-flow-syntax
package main
import (
"fmt"
"math"
"strings"
)
const (
BUFSIZE = 16
@samuell
samuell / gc_count.exs
Last active October 7, 2016 04:16 — forked from behe/gc_count.exs
defmodule ATGCCount do
def count(sequence), do: cnt(String.to_char_list(sequence),0,0)
def cnt([65|t],at,gc), do: cnt(t,at+1,gc)
def cnt([84|t],at,gc), do: cnt(t,at+1,gc)
def cnt([71|t],at,gc), do: cnt(t,at,gc+1)
def cnt([67|t],at,gc), do: cnt(t,at,gc+1)
def cnt([62|_],at,gc), do: {at,gc}
def cnt([],at,gc), do: {at,gc}
# def cnt(_,0,0), do: {0,0}
def cnt([_|t], at, gc), do: cnt(t,at,gc)
SELECT node.title,timestamp,node_revisions.body
FROM node
LEFT JOIN node_revisions ON node.vid=node_revisions.vid
INTO OUTFILE '/tmp/nodes.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n';
sudo yum install kernel-devel-2.6.32-504.16.2.el6.x86_64
sudo yum install gcc
sudo /etc/init.d/vboxadd setup
  1. General Background and Overview
// Defining two components, with a command-line pattern
fooWriter := sp.Sh("echo 'foo' > {o:outfile}")
fooToBarReplacer := sp.Sh("cat {i:foofile} | sed 's/foo/bar/g' > {o:barfile}")
// Implementing the functions for generating an output file name
fooWriter.OutPathFuncs["outfile"] = func() string {
// Just statically create a file named foo.txt
return "foo.txt"
}
fooToBarReplacer.OutPathFuncs["barfile"] = func() string {
// Put these in your ~/.bash_aliases file and refresh it with "source ~/.bash_aliases"!
// With this command, you create bookmarks of the current folder, by typing:
// bookmark somename
// ... then you can cd into that folder with "csomename" ("c" being short for "cd")
// You can also view all current such bookmarks with the "bookmarks" command.
bookmark() {
if [[ ! $1 ]]; then
echo "Usage: bookmark BOOKMARKNAME";
else
@samuell
samuell / go1.5build_error.log
Created March 3, 2015 01:14
Go 1.5 build error in Phusion Ubuntu Docker base image
--- FAIL: TestGdbPython (0.76s)
runtime-gdb_test.go:90: info goroutines failed: END
BEGIN print mapvar
No symbol "mapvar" in current context.