Skip to content

Instantly share code, notes, and snippets.

View 345161974's full-sized avatar
🎯
Focusing

Lucas 345161974

🎯
Focusing
View GitHub Profile
package main
import (
"database/sql"
"gopkg.in/gorp.v1"
"log"
"strconv"
"github.com/gin-gonic/gin"
_ "github.com/go-sql-driver/mysql"
@345161974
345161974 / answer_pic.go
Created May 1, 2017 06:18 — forked from tetsuok/answer_pic.go
An answer of the exercise: Slices on a tour of Go
package main
import "code.google.com/p/go-tour/pic"
func Pic(dx, dy int) [][]uint8 {
// Allocate two-dimensioanl array.
a := make([][]uint8, dy)
for i := 0; i < dy; i++ {
a[i] = make([]uint8, dx)
}
@345161974
345161974 / answer_word_count.go
Created May 1, 2017 06:48 — forked from tetsuok/answer_word_count.go
An answer of the exercise: Maps on a tour of Go
package main
import (
"code.google.com/p/go-tour/wc"
"strings"
)
func WordCount(s string) map[string]int {
m := make(map[string]int)
a := strings.Fields(s)
@345161974
345161974 / setup.py
Created May 10, 2017 04:40 — forked from stlehmann/setup.py
py2exe setup script for PyQt5 application including matplotlib, numpy, scipy, pandas
#! python3.4
from setuptools import setup
import os
import py2exe
import matplotlib
includes = ["sip",
"PyQt5",
"PyQt5.QtCore",
"PyQt5.QtGui",
@345161974
345161974 / mongo_backup.sh
Created May 16, 2017 08:27 — forked from sheharyarn/mongo_backup.sh
Mongodump Shell Script for Cronjob
#!/bin/bash
MONGO_DATABASE="your_db_name"
APP_NAME="your_app_name"
MONGO_HOST="127.0.0.1"
MONGO_PORT="27017"
TIMESTAMP=`date +%F-%H%M`
MONGODUMP_PATH="/usr/bin/mongodump"
BACKUPS_DIR="/home/username/backups/$APP_NAME"
@345161974
345161974 / mgoExample.go
Created June 4, 2017 09:27 — forked from border/mgoExample.go
mgo example
package main
import (
"fmt"
"labix.org/v2/mgo"
"labix.org/v2/mgo/bson"
"time"
)
type Person struct {
@345161974
345161974 / GoMgoSample-1.go
Created June 12, 2017 06:27 — forked from ardan-bkennedy/GoMgoSample-1.go
Sample Go and MGO example
type (
// BuoyCondition contains information for an individual station.
BuoyCondition struct {
WindSpeed float64 `bson:"wind_speed_milehour"`
WindDirection int `bson:"wind_direction_degnorth"`
WindGust float64 `bson:"gust_wind_speed_milehour"`
}
// BuoyLocation contains the buoy's location.
BuoyLocation struct {
@345161974
345161974 / gist:63573abdf1dc9c303d6740fb29496657
Created August 16, 2017 04:56 — forked from waqasjamal-zz/gist:7428185
Python Code for adding posts to WordPress remotely
import urllib
from wordpress_xmlrpc import Client, WordPressPost
from wordpress_xmlrpc.methods import posts
import xmlrpclib
from wordpress_xmlrpc.compat import xmlrpc_client
from wordpress_xmlrpc.methods import media, posts
import os
########################### Read Me First ###############################
'''
------------------------------------------In DETAIL--------------------------------
@345161974
345161974 / simp_zoom.py
Created December 4, 2017 04:10 — forked from tacaswell/simp_zoom.py
factory for adding zoom callback to matplotlib graphs
import matplotlib.pyplot as plt
def zoom_factory(ax,base_scale = 2.):
def zoom_fun(event):
# get the current x and y limits
cur_xlim = ax.get_xlim()
cur_ylim = ax.get_ylim()
# set the range
cur_xrange = (cur_xlim[1] - cur_xlim[0])*.5
@345161974
345161974 / timespec_diff.c
Created January 18, 2018 07:03 — forked from diabloneo/timespec_diff.c
Calculate diff of two struct timespec
#include <time.h>
void timespec_diff(struct timespec *start, struct timespec *stop,
struct timespec *result)
{
if ((stop->tv_nsec - start->tv_nsec) < 0) {
result->tv_sec = stop->tv_sec - start->tv_sec - 1;
result->tv_nsec = stop->tv_nsec - start->tv_nsec + 1000000000;
} else {
result->tv_sec = stop->tv_sec - start->tv_sec;