Skip to content

Instantly share code, notes, and snippets.

View xgdgsc's full-sized avatar

xgdgsc

  • Beijing,China
  • 09:01 (UTC +08:00)
View GitHub Profile
@AtlasPilotPuppy
AtlasPilotPuppy / SparkHbaseALS.scala
Last active August 29, 2015 14:03
Uses values in hbase tables to train and test ALS model in MLib.
import org.apache.spark.rdd.NewHadoopRDD
import org.apache.hadoop.hbase.mapreduce.TableInputFormat
import org.apache.hadoop.hbase.HBaseConfiguration
import org.apache.hadoop.hbase.client.Result
import org.apache.hadoop.hbase.io.ImmutableBytesWritable
import scala.collection.JavaConversions._
import scala.collection.JavaConverters._
import org.apache.spark.mllib.recommendation.ALS
import org.apache.spark.mllib.recommendation.Rating
import scala.collection.mutable.ArrayBuffer
@groundwater
groundwater / asynchbase.scala
Created April 20, 2012 17:47
Demo Adapting asynchbase to Scala
package ca.underflow.hbase
import org.hbase.async._
import com.stumbleupon.async._
object Demo extends App {
// This let's us pass inline functions to the deferred
// object returned by most asynchbase methods
@seperman
seperman / AutoHotkey_ErgoKeyboard
Last active June 24, 2020 06:22
Auto Hot Key configs to make Windows shortcuts/keyboard like Mac
; IMPORTANT INFO ABOUT GETTING STARTED: Lines that start with a
; semicolon, such as this one, are comments. They are not executed.
; This script has a special filename and path because it is automatically
; launched when you run the program directly. Also, any text file whose
; name ends in .ahk is associated with the program, which means that it
; can be launched simply by double-clicking it. You can have as many .ahk
; files as you want, located in any folder. You can also run more than
; one .ahk file simultaneously and each will get its own tray icon.
@jgarzik
jgarzik / boostgz.cc
Created May 17, 2012 04:03
Append a line of text to a gzip-compressed text file.
/*
Compile on Fedora 16 Linux:
g++ -O2 -Wall -g -o boostgz boostgz.cc -lboost_iostreams-mt
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fstream>
#include <iostream>
@copperlight
copperlight / .bashrc
Created August 11, 2016 16:27
Window Subsystem for Linux ssh-agent Configuraton
# ... more above ...
# wsfl bash is not a login shell
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi
# ssh-agent configuration
if [ -z "$(pgrep ssh-agent)" ]; then
rm -rf /tmp/ssh-*
@tshort
tshort / julia_type.md
Created October 4, 2012 18:58
Convert a string to a Julia type
@claws
claws / authentication.py
Last active July 24, 2021 19:37
An authentication module for pyzmq based on zauth from czmq. See the included test file for usage. To run the test function use: python test_authentication.py
'''
An authentication module for pyzmq modelled on zauth from czmq.
The functions to read and generate certificates should be interoperable
with czmq's zcert's - though are not as fully featured.
'''
import datetime
import glob
import json
@beugley
beugley / ExecAsynch.sas
Last active November 7, 2022 15:23
SAS macro to improve performance/effiiciency via parallel processing
Run time performance of your SAS process can be greatly improved with parallel execution.
This gist describes an approach where your input data set(s) are divided into N equal-sized subsets and your code is
executed in parallel against each subset. For information on other methods of parallel processing, please see this page
from SAS Support: http://support.sas.com/rnd/scalability/tricks/connect.html
Step 1
Divide your input data set(s) into N subsets that are approximately equal in size. The following macro shows one way to
do this.
%macro DIVIDE_INPUT_DATA(N);
@xgdgsc
xgdgsc / punzip.py
Last active December 4, 2022 11:33
python script to extract zip with GBK encoding
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
# file: unzip.py
import zipfile,os,sys
if len(sys.argv)==2:
fname=sys.argv[1]
else:
print "Usage: python %s filename\n\n" % sys.argv[0]
sys.exit()
@senko
senko / onchange.sh
Last active July 14, 2023 07:54
OnChange - Watch current directory and execute a command if anything in it changes
#!/bin/bash
#
# Watch current directory (recursively) for file changes, and execute
# a command when a file or directory is created, modified or deleted.
#
# Written by: Senko Rasic <senko.rasic@dobarkod.hr>
#
# Requires Linux, bash and inotifywait (from inotify-tools package).
#
# To avoid executing the command multiple times when a sequence of