Skip to content

Instantly share code, notes, and snippets.

(defun xsel-select-text (text &optional push)
"See `x-select-text'."
(let* ((process-connection-type nil)
(proc (start-process "xsel" nil "xsel" "-b" "-i")))
(process-send-string proc text)
(process-send-eof proc)))
(defun xsel-selection-value ()
"See `x-cut-buffer-or-selection-value'."
(shell-command-to-string "xsel -b -o"))
@pclouds
pclouds / gist:334003
Created March 16, 2010 14:15
git-peer.sh
#!/bin/sh
. git-sh-setup
URL="$1"
host=${URL/:*/}
path=${URL/*:/}
ssh "$host" git ls-peer "$path" > $GIT_DIR/peer.tmp
eval `sed -n '1,/^$/p' $GIT_DIR/peer.tmp`
@pclouds
pclouds / git-ls-peer.sh
Created March 16, 2010 14:15
git-ls-peer.sh
#!/bin/sh
export GIT_DIR="$1"
echo "name=$(git config repo.name)"
echo "url=$(git config repo.url)"
echo
for i in $(git remote);do
git config remote.$i.url
done
#include <stdio.h>
#include <string.h>
#include <gettext-po.h>
#include <unistd.h>
static void
err(int severity,
po_message_t msg, const char *filename, size_t lineno,
size_t column, int multiline_p, const char *msgstr)
{
From ca71ec8926ab5b640fcb566c324c17b2639680a4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= <pclouds@gmail.com>
Date: Sun, 3 Jul 2011 17:52:25 +0700
Subject: [PATCH] dash: grab keyboard after Super is pressed
---
js/ui/overview.js | 43 ++++++++++++++++++++++++++++++++++++++-----
1 files changed, 38 insertions(+), 5 deletions(-)
diff --git a/js/ui/overview.js b/js/ui/overview.js
@pclouds
pclouds / test-gen-tree-cache.c
Created April 5, 2012 12:46
Tree cache generator
#include "cache.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <zlib.h>
#include <unistd.h>
#include <stdint.h>
int encode_varint(unsigned int value, char *buf)
@pclouds
pclouds / pit.scm
Created August 3, 2012 13:40
PIT calculation
#!/usr/bin/scheme-r5rs
;; Calculate Vietnam Personal Income Tax
;; Input in million VND
(let* ((thresholds '((09 . 0.00)
(02 . 0.05)
(03 . 0.10)
(05 . 0.15)
(10 . 0.20)
(20 . 0.25)
;; Define your own rules here
;; return a pair of server address and port
(define (choose-proxy host)
(values host 80))
(define (http-read-line port)
(read-line port #\newline #t))
(define (read-write read-port write-port)
(define (do-read-write read-port write-port)
(define-cise-macro define-enums
[(_ sym ...) (for-each define-enum sym ...)])
import colorsys
CLUT = [ # color look-up table
# 8-bit, RGB hex
# Primary 3-bit (8 colors). Unique representation!
('00', '000000'),
('01', '800000'),
('02', '008000'),
('03', '808000'),