Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
# bgxupdate - update active processes in a group.
# Works by transferring each process to new group
# if it is still active.
# in: bgxgrp - current group of processes.
# out: bgxgrp - new group of processes.
# out: bgxcount - number of processes in new group.
bgxupdate() {
@jcppkkk
jcppkkk / gist:2762736
Created May 21, 2012 14:50
[python] Basics
## Dict Database for col_fam.batch_insert()
a={}
for r in range(3):
row_key='raw{}'.format(r)
a[row_key]={}
for i in range (5):
a[row_key]['name{}'.format(i)]='val{}'.format(i)
print a
##{'raw2': {'name4': 'val4', 'name2': 'val2', 'name3': 'val3', 'name0': 'val0', 'name1': 'val1'},
@jcppkkk
jcppkkk / Makefile
Created June 5, 2012 13:18 — forked from shafreeck/Makefile
Makefile example
all: hello
hello: hello.h
g++ -o hello hello.cpp
clean:
rm *.o hello
@jcppkkk
jcppkkk / gist:3293436
Created August 8, 2012 08:33
Get topTask and it's PID
static final String TAG = "XXX_TAG"
am = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
RunningTaskInfo topTask = am.getRunningTasks(1).get(0);
String pkg = topTask.baseActivity.getPackageName();
int pid = findForgroundPID(pkg);
private int findForgroundPID(String topPackage) {
int pid = -1;
List<RunningAppProcessInfo> procList = am.getRunningAppProcesses();
for (RunningAppProcessInfo proc : procList) {
@jcppkkk
jcppkkk / gist:3909904
Created October 18, 2012 04:51
rdiff-backup statistics
root@bbs[ /home/BBSBACKUP ] > rdiff-backup --calculate-average rdiff-backup-data /session_statistics.2012-*
--------------[ Average of 5 stat files ]--------------
ElapsedTime 686.29 (11 minutes 26.29 seconds)
SourceFiles 470907.8
SourceFileSize 3107723617.8 (2.89 GB)
MirrorFiles 448015.6
MirrorFileSize 2984598578.2 (2.78 GB)
NewFiles 23082.8
NewFileSize 125044623.6 (119 MB)
DeletedFiles 190.6
@jcppkkk
jcppkkk / gist:4149704
Created November 26, 2012 18:07
Boyer-Moore algorithm
#define MAX(a,b) \
({ __typeof__ (a) _a = (a); \
__typeof__ (b) _b = (b); \
_a > _b ? _a : _b; })
#include <stdio.h>
#include <string.h>
#define XSIZE 20
#define ASIZE 256
@jcppkkk
jcppkkk / install.sh
Created November 29, 2012 02:12 — forked from alvin2ye/install.sh
Automaticlly install pptpd on Ubuntu 12.04
# Authors: Alvin Ye
# Run by: curl -sL https://gist.github.com/1471830.txt | sudo bash
sudo apt-get install pptpd
sed -i 's/^logwtmp/#logwtmp/g' /etc/pptpd.conf
sed -i 's/^net.ipv4.ip_forward = 0/net.ipv4.ip_forward = 1/g' /etc/sysctl.conf
sysctl -p
echo "localip 192.168.240.1" >> /etc/pptpd.conf
Sub SendMessage()
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment
' Create the Outlook session.
Set objOutlook = CreateObject("Outlook.Application")
' Create the message.
@jcppkkk
jcppkkk / gist:6409139
Last active September 30, 2023 15:49
Cookie clicker assistant (Bookmarklet) store the code as a bookmark, then click it when you are in Cookie clicker.
javascript: (function () {
function loadScript(b, c) {
var a = document.createElement("script");
a.type = "text/javascript";
if (a.readyState) {
a.onreadystatechange = function () {
if (a.readyState == "loaded" || a.readyState == "complete")
{a.onreadystatechange = null; c() } }
} else {a.onload = function () {c() } } a.src = b;
document.getElementsByTagName("head")[0].appendChild(a)
@jcppkkk
jcppkkk / gist:6522576
Created September 11, 2013 11:56
Load Cookie Monster and Highlighter
javascript: (function () {
function loadScript(b, c) {
var a = document.createElement("script");
a.type = "text/javascript";
if (a.readyState) {
a.onreadystatechange = function () {
if (a.readyState == "loaded" || a.readyState == "complete")
{a.onreadystatechange = null; c() } }
} else {a.onload = function () {c() } } a.src = b;
document.getElementsByTagName("head")[0].appendChild(a)