Skip to content

Instantly share code, notes, and snippets.

View southwolf's full-sized avatar

SouthWolf southwolf

  • HSBC
  • Guangzhou, China
View GitHub Profile
@southwolf
southwolf / Pebble.ino
Last active January 26, 2020 20:40
Arduino code for Communicate with Pebble
#include <string.h>
#include <ctype.h>
#include <SoftwareSerial.h>
// the Bluetooth Shield connects to Pin D9 & D10
SoftwareSerial bt(9,10);
const uint8_t req[5] = {0x00, 0x01, 0x00, 0x11, 0x00};
const uint8_t cap[17] = {0x00, 0x0d, 0x00, 0x11, 0x01, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32};
const uint8_t ping[9] = {0x00, 0x05, 0x07, 0xd1, 0x00, 0xde, 0xad, 0xbe, 0xef};
@southwolf
southwolf / az_vm.tf
Created December 21, 2019 04:24
Create azure vm
provider "azurerm" {
version = "=1.38.0"
subscription_id = "91e51453-1db3-46d0-8329-423542539317"
}
# Create a resource group
resource "azurerm_resource_group" "rg" {
name = "tf_resource_group"
location = "westus2"
@southwolf
southwolf / stats.js
Created January 21, 2019 03:14 — forked from izaac/stats.js
An example statistics library in Javascript.
#!/usr/bin/env node
/* jshint node: true */
'use strict';
var program = require('commander');
function add(a, b){
return a + b;
}
function numericSort(a,b) {
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
annotations:
pv.kubernetes.io/bind-completed: "yes"
pv.kubernetes.io/bound-by-controller: "yes"
volume.beta.kubernetes.io/storage-provisioner: kubernetes.io/aws-ebs
labels:
app: mongodb
chart: mongodb-3.0.4
@southwolf
southwolf / main.go
Created May 7, 2018 14:45 — forked from enricofoltran/main.go
A simple golang web server with basic logging, tracing, health check, graceful shutdown and zero dependencies
package main
import (
"context"
"flag"
"fmt"
"log"
"net/http"
"os"
"os/signal"
@southwolf
southwolf / fontgen.py
Created April 25, 2013 22:42
Modified fontgen.py to generate basic ASCII & Russian, by changine the codepoints
#!/usr/bin/env python
# coding=utf-8
import argparse
import freetype
import os
import re
import struct
import sys
import itertools
from math import ceil
@southwolf
southwolf / eventmachine.rb
Created September 16, 2017 14:21 — forked from marianposaceanu/eventmachine.rb
Initializer that allows EventMachine to run within Rails, and work with AMQP, Passenger, Thin and Capybara
require 'amqp'
module HiringThingEM
def self.start
if defined?(PhusionPassenger)
PhusionPassenger.on_event(:starting_worker_process) do |forked|
# for passenger, we need to avoid orphaned threads
if forked && EM.reactor_running?
EM.stop
end
Thread.new {
project :test => :shoulda, :renderer => :haml, :stylesheet => :sass, :script => :jquery, :orm => :activerecord
#default routes
APP_INIT = <<-APP
get "/" do
"Hello World!"
end
get :about, :map => '/about_us' do
render :haml, "%p This is a sample blog created to demonstrate the power of Padrino!"
project :test => :shoulda, :renderer => :haml, :stylesheet => :sass, :script => :jquery, :orm => :activerecord
#default routes
APP_INIT = <<-APP
get "/" do
"Hello World!"
end
get :about, :map => '/about_us' do
render :haml, "%p This is a sample blog created to demonstrate the power of Padrino!"
@southwolf
southwolf / post.rb
Created March 26, 2017 12:06
Ruby will crash when forgetting to append `result` after `ransack()`
class Post < ActiveRecord::Base
end