Skip to content

Instantly share code, notes, and snippets.

View ear7h's full-sized avatar
🚲
now on a bike

Julio ear7h

🚲
now on a bike
View GitHub Profile
@ear7h
ear7h / foreigninsert.sql
Last active August 27, 2017 07:55
Insert values from other tables
#table declaration
CREATE TABLE `prices_by_seconds` (
`ask_price` double,
`ask_size` int(11),
`bid_price` double,
`bid_size` int(11),
`last_trade_price` double,
`symbol` varchar(8),
`updated_at` datetime
@ear7h
ear7h / goto.go
Created August 27, 2017 08:43
learned about goto statements in Go and actually found a use case
func getMarketHours() (time.Time, time.Time) {
url := "https://api.robinhood.com/markets/XNAS/hours/" + time.Now().Format("2006-01-02") + "/"
//tag for goto statement
L:
//get today's market info
res, err := http.Get(url)
if err != nil {
panic(err)
}
@ear7h
ear7h / server.java
Created March 3, 2018 19:53
Simple server class, has some hints at working to a file server
import com.sun.net.httpserver.*;
import java.io.IOException;
import java.net.InetSocketAddress;
public class Server {
public static void main(String[] args) throws IOException{
@ear7h
ear7h / map_v_oslice_test.go
Created June 21, 2018 00:09
map vs ordered slice benchmark
package db_test
import (
"testing"
"math/rand"
"sort"
"time"
"fmt"
"encoding/base64"
)
{
"version": 8,
"name": "camo",
"metadata": {
"mapbox:autocomposite": false,
"mapbox:type": "template",
"openmaptiles:version": "3.x",
"maputnik:renderer": "mbgljs",
"inspect": true
},
@ear7h
ear7h / README.md
Last active August 20, 2018 21:07
mbgl issue images

out1.png, out2.png

@ear7h
ear7h / binary2struct.nim
Created September 13, 2018 00:18
reading in a struct (with only static sized types) in Nim
type
SomeStruct = object
longPtr: uint64
length: uint32
var x: ptr SomeStruct
var dat: array[12, char]
for ch in mitems(dat):
ch = high(char)
@ear7h
ear7h / carr.c
Created March 17, 2019 00:32
String literal allocation in C
#include <stdio.h>
char * mkstr() {
return "some data";
}
char * mkstr1() {
return "data some";
}
@ear7h
ear7h / out.txt
Created March 17, 2019 08:00
C++ virtual semantics
void * 8
C0 4
C1 16
C11 8
C2 24
C3 8
C4 32
pt 32
c4->a 0x101457120
@ear7h
ear7h / pafile
Last active May 14, 2019 18:16
script to generate pa files
#!/usr/bin/env python
# uses python 3
# usage: pafile filename [pretty name]
# the file must not exist
import sys
from datetime import date
raise Exception('remove me and fill in `userid` and `author`')