Skip to content

Instantly share code, notes, and snippets.

@snaka
snaka / twitter_notifier.rb
Created April 11, 2009 04:12
Ruby/GNTP example: twitter notifier
#!/usr/bin/ruby
#
# Ruby/GNTP example : twitter notifier
#
# Usage: {{{
# Please type the following command from command line,
# and then, this script gets your time-line every 30 seconds.
#
# > ruby twitter_notifyer.rb
#
@snaka
snaka / gntp-notify
Created April 14, 2009 06:31
Ruby/GNTP example : Growl notifier command
#!/usr/bin/ruby
# Growl notifier command
# Usage:
# gntp-notify [message]
# License:
# public domain
require "rubygems"
require "ruby_gntp" # >= ver.0.1.0
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
int
main()
{
int sock0;
struct sockaddr_in addr;
//
// socket client sample
//
socket = (function(){
logCrear();
log("start");
var socketService = Components.classes["@mozilla.org/network/socket-transport-service;1"]
.getService(Components.interfaces.nsISocketTransportService);
#include <stdio.h>
#include <winsock2.h>
void sendAndRecieve(char *message) {
struct sockaddr_in server;
SOCKET sock;
char buf[2048];
// Create socket
sock = socket(AF_INET, SOCK_STREAM, 0);
@snaka
snaka / sjis_to_utf8.cpp
Created April 29, 2009 17:52
SJIS to UTF-8 convert code by MS VC++
#include <stdio.h>
#include <windows.h>
BOOL convSJIStoUTF8( BYTE* pSource, BYTE* pDist, int* pSize )
{
*pSize = 0;
// Convert SJIS -> UTF-16
const int nSize = ::MultiByteToWideChar( CP_ACP, 0, (LPCSTR)pSource, -1, NULL, 0 );
liberator.plugins.sqliteReorg = (function(){
const ss = Cc["@mozilla.org/storage/service;1"].getService(Ci.mozIStorageService);
function getSQLiteFiles(){
let profDir = services.get("directory").get("ProfD", Ci.nsIFile);
let files = profDir.directoryEntries;
let reg = new RegExp("\\.sqlite$");
while (files.hasMoreElements()){
let file = files.getNext().QueryInterface(Ci.nsIFile);
if (file.isFile() && reg.test(file.leafName)){
yield file;
#
# biff.rb
# Simple biff(Mail check and notify tool)
#
# This script is example of Ruby/GNTP library
# (http://snaka.github.com/ruby_gntp/)
#
# Setup:
# you need follown gems.
# - ruby_gntp
@snaka
snaka / CanvasSample.html
Created May 9, 2009 10:17
Canvasでテキストと角丸四角形を描画するサンプル
<html>
<head>
<title>Canvas tutorial</title>
<script type="text/javascript">
var ctx = null;
function draw(){
var canvas = document.getElementById('tutorial');
if (canvas.getContext){
ctx = canvas.getContext('2d');
@snaka
snaka / cheatSheet.js
Created May 10, 2009 15:19
**まだ作成中**
// Cheat sheet generator command for Vimperator
plugins.cheat_sheet = (function () {
commands.addUserCommand(
["cheat"],
"Show cheat sheet",
function(args) {
showCheatSheet();
},
null,