Skip to content

Instantly share code, notes, and snippets.

View shicky's full-sized avatar

Steve shicky

View GitHub Profile
@shicky
shicky / golang_coverage.md
Last active October 7, 2016 04:56
Generating coverage report for Golang

Generating golang coverage report

go test -cover -coverprofile=c.out
go tool cover -html=c.out
@shicky
shicky / ld_preload_hook.c
Last active June 27, 2024 12:25
LD_PRELOAD linux function hook example
# helloworld.c
# gcc helloworld.c -o helloworld
#include <stdio.h>
#include <unistd.h>
int main() {
puts("Hello world!\n");
return 0;
}
package main
import "github.com/miekg/dns"
// ResolveIP resolves IP address using provided DNS server
func ResolveIP(url, server string) (string, error) {
msg := new(dns.Msg)
msg.Id = dns.Id()
msg.RecursionDesired = true
msg.Question = make([]dns.Question, 1)
@shicky
shicky / reflect_convert.go
Created July 15, 2016 10:35
Convert reflect.Value to appropriate variable
package gocelery
import (
"reflect"
"strconv"
)
// GetRealValue returns real value of reflect.Value
func GetRealValue(val reflect.Value) interface{} {
switch val.Kind() {
package main
import (
"fmt"
"reflect"
)
func main() {
// register method
tasks := make(map[string]interface{})
tasks["add"] = add
@shicky
shicky / algorithm.java
Last active July 13, 2016 06:11
Java Syntax
public static void main(String[] args) {
// data type and max values
/*
width minimum maximum
byte: 8 bit -128 +127
short: 16 bit -32 768 +32 767
int: 32 bit -2 147 483 648 +2 147 483 647
long: 64 bit -9 223 372 036 854 775 808 +9 223 372 036 854 775 807
float: 32 bit 1.4E-45 3.402,823,5E+38
@shicky
shicky / init_double_dict.py
Created July 11, 2016 03:04
Initialize Python Double Dict with -1
from collections import defaultdict
d = defaultdict(lambda: defaultdict(lambda: -1))
print(d[544][465]) # should be -1
package main
import (
"fmt"
"sync"
"time"
)
type Job struct {
url string
const React = require('react');
// sample callback
function onCheckboxClicked(e, id) {
console.log(e.target.id);
console.log(e.target.checked);
//store.dispatch(ReduxActions.updateSomething(something));
}
const CheckboxInput = React.createClass({
@shicky
shicky / react_onchange_technique.js
Last active June 16, 2016 10:34
Handling checkbox
const Form = require('react-bootstrap/lib/Form');
const FormGroup = require('react-bootstrap/lib/FormGroup');
const FormControl = require('react-bootstrap/lib/FormControl');
const Col = require('react-bootstrap/lib/Col');
const ControlLabel = require('react-bootstrap/lib/ControlLabel');
onChangeValue(evt, check=false) {
this.setState({[evt.target.id]: check?evt.target.checked:evt.target.value});
},