Skip to content

Instantly share code, notes, and snippets.

@0x5d
0x5d / capturedVars.go
Last active March 30, 2016 20:35
A small piece of code to illustrate vars captured by range expressions in Golang.
package main
import (
"fmt"
"sync"
)
func main() {
// My opinions on people.
peopleOpinions := map[string]string{
@0x5d
0x5d / get-net-info.sh
Created December 13, 2015 23:59
Get network controller info.
#! /bin/bash
lspci -knn | grep Net -A2
socket.on('file', function (arrayBuffer) {
// Build a Blob from an ArrayBuffer
var blob = new Blob([arrayBuffer])
doSomethingMagicWithBlobs(blob)
// Voilà
})
@0x5d
0x5d / socket-io-client-1.js
Last active November 9, 2015 18:32
Socket.io client emitting example.
// called when a sound was encoded successfully.
function doneEncoding (blob) {
// do some stuff...
socket.emit('file', blob)
// do more stuff...
}
@0x5d
0x5d / socket-io-server.js
Created November 9, 2015 18:25
A socket io file handling example.
// Let's assume io was initialized, like var io = require('socket.io')(app)
io.on('connection', function (socket) {
socket.on('file', function (file) {
socket.emit('file', file)
})
})
package com.mycompany.myfirstapp.activity.weather;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import java.io.IOException;
import com.mycompany.myfirstapp.service.WeatherInfoService;
import com.mycompany.myfirstapp.model.weather.WeatherInfo;
package com.mycompany.myfirstapp.service;
import com.mycompany.myfirstapp.api.WeatherInfoApi;
import java.io.IOException;
import retrofit.Callback;
import retrofit.GsonConverterFactory;
import retrofit.Retrofit;
package com.mycompany.myfirstapp.api;
import com.mycompany.myfirstapp.model.weather.WeatherInfo;
import retrofit.Call;
import retrofit.http.GET;
import retrofit.http.Query;
public interface WeatherInfoApi {
@GET("/data/2.5/weather")
package com.mycompany.myfirstapp.model.weather;
public class Weather {
private String description;
public String getDescription() {
return description;
}
package com.mycompany.myfirstapp.model.weather;
public class WeatherInfo {
private Weather[] weather;
private String name;
public Weather[] getWeather() {
return weather;
}