Skip to content

Instantly share code, notes, and snippets.

View mssola's full-sized avatar
🏠
Working from home

Miquel Sabaté Solà mssola

🏠
Working from home
View GitHub Profile
@mssola
mssola / consumer_producer.go
Last active December 18, 2015 20:29
A simple solution to the classic problem of the "producer-consumer" in Go.
package main
import (
"fmt"
"math/rand"
)
const N_WORKERS = 10
func producer(c chan int) {
@cjus
cjus / jsonval.sh
Created June 26, 2011 17:42
Extract a JSON value from a BASH script
#!/bin/bash
function jsonval {
temp=`echo $json | sed 's/\\\\\//\//g' | sed 's/[{}]//g' | awk -v k="text" '{n=split($0,a,","); for (i=1; i<=n; i++) print a[i]}' | sed 's/\"\:\"/\|/g' | sed 's/[\,]/ /g' | sed 's/\"//g' | grep -w $prop`
echo ${temp##*|}
}
json=`curl -s -X GET http://twitter.com/users/show/$1.json`
prop='profile_image_url'
picurl=`jsonval`