Skip to content

Instantly share code, notes, and snippets.

View jokester's full-sized avatar
🌛
not my photo / still alive and with a cat now!!! (as of 2024-03)

Wang Guan jokester

🌛
not my photo / still alive and with a cat now!!! (as of 2024-03)
View GitHub Profile
#!/usr/bin/env bash
if which mit-scheme &>/dev/null ; then
if [ $# -gt 0 ]; then
mit-scheme --quiet < $1
else
echo "usage: $0 [scheme src]"
fi
else
echo "'mit-scheme' executable not found"
fi
(define (inc i) (+ i 1))
(define (product1 term a next b)
(if (> a b)
1
(* (term a)
(product1 term (next a) next b))))
(define (product2 term a next b)
(define (iter a result)
@jokester
jokester / Packages.txt
Created March 3, 2015 00:55
Psychtoolbox: problem loading movie file of particular format
% dpkg -l | egrep -i "psych|gstream|libgcc|libgl1|libglu1"
ii gir1.2-gst-plugins-base-1.0 1.2.4-1~ubuntu1 amd64 Description: GObject introspection data for the GStreamer Plugins Base library
ii gir1.2-gstreamer-1.0 1.2.4-0ubuntu1 amd64 Description: GObject introspection data for the GStreamer library
ii gstreamer0.10-alsa:amd64 0.10.36-1.1ubuntu2 amd64 GStreamer plugin for ALSA
ii gstreamer0.10-fluendo-mp3:amd64 0.10.23.debian-3 amd64 Fluendo mp3 decoder GStreamer 0.10 plugin
ii gstreamer0.10-nice:amd64 0.1.4-1 amd64 ICE library (GStreamer 0.10 plugin)
ii gstreamer0.10-plugins-bad:amd64 0.10.23-7.2ubuntu1 amd64 GStreamer plugins from the "bad" set
ii gstreamer0.10-plugins-base:amd64 0.10.36-1.1ubuntu2
@jokester
jokester / simple_http_server.rb
Created April 25, 2015 01:36
a simplehttpserver in ruby
#!/usr/bin/env ruby
require 'rack'
require 'socket'
require 'optparse'
ENV['RACK_ENV'] = "production"
# Options :
# --root (mandatory)
# --port (optional)
@jokester
jokester / PixelExtractor.swift
Last active January 4, 2022 07:27
extract pixel from a CGImage
// extract pixel from a CGImage
/* use case:
let extractor = PixelExtractor(img: UIImage(named: "gauge_vertical")!.CGImage!)
let color = extractor.color_at(x: 10, y: 20)
*/
class PixelExtractor {
// taken from http://stackoverflow.com/questions/24049313/
// and adapted to swift 1.2
import java.util.*;
import java.io.*;
import java.security.*;
public class ChangePassword
{
private final static JKS j = new JKS();
public static void main(String[] args) throws Exception
{
@jokester
jokester / MyLogging.hs
Created September 22, 2015 15:22
Witness me!
import System.Environment (setEnv, lookupEnv)
doWriteLog :: Int -> Int -> String -> IO ()
doWriteLog logLevel messageLevel message
| messageLevel >= logLevel = putStrLn message
doWriteLog _ _ _ = return ()
setLogLevel :: Int -> IO ()
setLogLevel newLogLevel = do
setEnv "__loglevel" $ show newLogLevel
@jokester
jokester / 一個例子.js
Created October 31, 2015 01:11
只能由特定code使用的, 只定義一次的變數
document.getElementById('testbutton').onclick = (function () {
// 這邊的t和a只會定義一次
var t = Math.tan(Math.PI * 0.2);
var a;
// 下面的function每次實行時都會重復使用上面的t和a
// 其他code看不到上面的t和a
return function() {
var i = 0;
@jokester
jokester / screw-dell.sh
Created December 12, 2015 03:31
how to extract download link from the download list of dell's crappy support site
#!/bin/bash
set -o pipefail
set -e
# the link to download list can be obtained with "send the list via mail"
# mine was https://www.dell.com/support/home/jp/ja/jpdhs1/Drivers/DownloadListDetails?downloadListId=81a3eea8-706d-4fc4-bb41-a17754e291c5
curl "https://www.dell.com/support/home/jp/ja/jpdhs1/Drivers/DownloadListDetails?downloadListId=81a3eea8-706d-4fc4-bb41-a17754e291c5" \
| egrep --only-match 'http.*?\.exe' -i \
| xargs wget
@jokester
jokester / irb log.txt
Last active December 17, 2015 01:39
BCrypt uses first 72 bytes instead of 72 chars.
irb(main):011:0> pass1 = "あ" * 50
=> "ああああああああああああああああああああああああああああああああああああああああああああああああああ"
irb(main):012:0> pass1.size
=> 50
irb(main):013:0> pass1.bytes.size
=> 150