Skip to content

Instantly share code, notes, and snippets.

@indraniel
indraniel / read-file.scm
Created July 17, 2017 16:49
An example file reading script with chicken scheme
#!/usr/bin/env csi -ss
;; An example file reading script with chicken scheme
(use extras)
(define (read-it file)
(let ((fh (open-input-file file)))
(let loop((c (read-line fh)))
(if (eof-object? c)
// Source: https://github.com/nodejs/node/blob/master/lib/child_process.js
// Defines spawn_sync and normalizeSpawnArguments (without error handling). These are internal variables.
spawn_sync = process.binding('spawn_sync'); normalizeSpawnArguments = function(c,b,a){if(Array.isArray(b)?b=b.slice(0):(a=b,b=[]),a===undefined&&(a={}),a=Object.assign({},a),a.shell){const g=[c].concat(b).join(' ');typeof a.shell==='string'?c=a.shell:c='/bin/sh',b=['-c',g];}typeof a.argv0==='string'?b.unshift(a.argv0):b.unshift(c);var d=a.env||process.env;var e=[];for(var f in d)e.push(f+'='+d[f]);return{file:c,args:b,options:a,envPairs:e};}
// Defines spawnSync, the function that will do the actual spawning
spawnSync = function(){var d=normalizeSpawnArguments.apply(null,arguments);var a=d.options;var c;if(a.file=d.file,a.args=d.args,a.envPairs=d.envPairs,a.stdio=[{type:'pipe',readable:!0,writable:!1},{type:'pipe',readable:!1,writable:!0},{type:'pipe',readable:!1,writable:!0}],a.input){var g=a.stdio[0]=util._extend({},a.stdio[0])
@ivan-loh
ivan-loh / main.go
Created December 25, 2016 14:28
mongodb crud in golang
package main
import (
"fmt"
"gopkg.in/mgo.v2"
"gopkg.in/mgo.v2/bson"
"time"
)
type Person struct {
@Dr-ZeeD
Dr-ZeeD / scrapy_script.py
Created October 23, 2016 22:11
Scrapy one-file script with custom logging and click.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import logging
import click
from twisted.internet import reactor
from scrapy import Item, Spider
from scrapy.crawler import CrawlerRunner
from scrapy.settings import Settings
from scrapy.utils.log import configure_logging
@p4tin
p4tin / Mongo.go
Created December 13, 2015 18:06
Golang Mongo CRUD Example
package mongo
import (
"time"
"log"
"gopkg.in/mgo.v2"
"gopkg.in/mgo.v2/bson"
)
// Profile - is the memory representation of one user profile
@hyper0x
hyper0x / tcp_demo.go
Last active December 14, 2024 22:21
The interaction demo via TCP in Golang.
package main
import (
"bufio"
"bytes"
"fmt"
"io"
"log"
"net"
"os"
@danreedy
danreedy / gist:a0f0aa1ec2eb275c55a2
Created April 16, 2015 14:39
Frozen - Let it Go - Sonic Pi
# Let it Go - Pi Version
use_bpm 34
use_synth :pretty_bell
quaver = 0.125 #Eight note
crotchet = 0.25 #Quarter note
minim = 0.5 #Half note
semibreve = 1 #Whole note
in_thread(name: :rh) {rightHand}