Skip to content

Instantly share code, notes, and snippets.

@Happy-Ferret
Happy-Ferret / _ff-addon-snippet-gtkScreenshot.js
Created May 31, 2016 08:10 — forked from Noitidart/_ff-addon-snippet-gtkScreenshot.js
_ff-addon-snippet-gtkScreenshot - Takes screenshot of all monitors on on GTK systems. [jsctypes] [gtk] [gdk]
Cu.import('resource://gre/modules/ctypes.jsm');
var gdk2 = ctypes.open('libgdk-x11-2.0.so.0');
var _void = ctypes.void_t;
var gint = ctypes.int;
var GdkPixbuf = ctypes.StructType('GdkPixbuf');
var GdkDrawable = ctypes.StructType('GdkDrawable');
var GdkColormap = ctypes.StructType('GdkColormap');
var GdkWindow = ctypes.StructType('GdkWindow');
var guchar = ctypes.unsigned_char;
@Happy-Ferret
Happy-Ferret / _ff-addon-snippet-WinAPI_ShellExec.js
Created May 31, 2016 08:10 — forked from Noitidart/_ff-addon-snippet-WinAPI_ShellExec.js
_ff-addon-snippet-WinAPI_ShellExec - Launch things without waiting for response. [winapi] [jsctypes]
Cu.import('resource://gre/modules/ctypes.jsm')
var wintypesInit = function() {
var ifdef_UNICODE = true;
this.WINABI = ctypes.winapi_abi; //should do 64bit testing
// BASIC TYPES (ones that arent equal to something predefined by me)
this.BOOL = ctypes.bool;
this.CHAR = ctypes.char;
@Happy-Ferret
Happy-Ferret / libc_puts.js
Created June 1, 2016 18:42
Calling (g)libc's "puts()" from within javascript/js ctypes, writing a string to stdout.
/* import js-ctypes */
var {ctypes} = Components.utils.import("resource://gre/modules/ctypes.jsm", null);
/* Open the library */
try {
/* Linux */
var libc = ctypes.open("libc.so.6");
} catch (e) {
/* Most other Unixes */
libc = ctypes.open("libc.so");
@Happy-Ferret
Happy-Ferret / lolcat.hs
Created June 4, 2016 00:17 — forked from lest/lolcat.hs
simple lolcat powered by haskell
import Data.Word
freq = 0.3
spread = 8.0
unbase :: Integral int => int -> Word8 -> Word8 -> Word8 -> int
unbase base r g b = (fi r*base+fi g)*base+fi b
where fi = fromIntegral
-- | Approximate a 24-bit Rgb colour with a colour in the xterm256 6x6x6 colour cube, returning its index.
@Happy-Ferret
Happy-Ferret / lib.hs
Last active November 8, 2016 16:17
Mixed assembly (C/Haskell)
{-# LANGUAGE ForeignFunctionInterface #-}
module Test where
import Foreign.C.Types
hsfun :: CInt -> IO CInt
hsfun x = do
putStrLn "Hello from haskell"
return (42 * x)
hsfoo :: CInt -> IO CInt
@Happy-Ferret
Happy-Ferret / README.md
Created June 6, 2016 06:42 — forked from oodavid/README.md
Deploy your site with git

Deploy your site with git

This gist assumes:

  • you have a local git repo
  • with an online remote repository (github / bitbucket etc)
  • and a cloud server (Rackspace cloud / Amazon EC2 etc)
    • your (PHP) scripts are served from /var/www/html/
    • your webpages are executed by apache
  • apache's home directory is /var/www/
@Happy-Ferret
Happy-Ferret / ribbon.html
Created June 9, 2016 08:06
Github ribbon
http://terrenceryan.com/blog/index.php/github-ribbons-in-css/
@Happy-Ferret
Happy-Ferret / emoji_image_replace.js
Created June 9, 2016 09:40 — forked from mwunsch/emoji_image_replace.js
Detect emoji unicode on a page, replace it with images (supplied by GitHub, for now). Goes great in your ~/.js
/**
*
* Here's a thing that will look through all the text nodes of a document, and
* upon encountering an emoji codepoint, will replace it with an image.
* For now, those images are pulled from GitHub, which isn't very nice, so I
* need to find a more suitable host.
*
* Much of this code was gleaned from staring at the minified GitHub JS.
*
* Copyright (c) 2013 Mark Wunsch. Licensed under the MIT License.
@Happy-Ferret
Happy-Ferret / emolist.js
Created June 9, 2016 09:45 — forked from ptantiku/emolist.js
Javascript to print out all emoticons on Facebook. Usage: open javascript console on the browser (e.x. ctrl+shift+j) then paste the code in.
var emolist=[
{"chars" : " :) ", "class" : "emoticon_smile", "name" : "Smiley"},
{"chars" : " :( ", "class" : "emoticon_frown", "name" : "Frown"},
{"chars" : " :P ", "class" : "emoticon_tongue", "name" : "Tongue"},
{"chars" : " :D ", "class" : "emoticon_grin", "name" : "Grin"},
{"chars" : " :o ", "class" : "emoticon_gasp", "name" : "Gasp"},
{"chars" : " ;) ", "class" : "emoticon_wink", "name" : "Wink"},
{"chars" : " :v ", "class" : "emoticon_pacman", "name" : "Pacman"},
{"chars" : " >:( ", "class" : "emoticon_grumpy", "name" : "Gruñón"},
{"chars" : " :/ ", "class" : "emoticon_unsure", "name" : "Unsure"},
@Happy-Ferret
Happy-Ferret / _ff-addon-snippet-EnumWindows.js
Created June 15, 2016 13:26 — forked from Noitidart/_ff-addon-snippet-EnumWindows.js
_ff-addon-snippet-EnumWindows - Using js-ctypes to try to do a EnumWindows with callback.
//https://github.com/nightwing/foximirror/blob/f40afb12beb512fb1d453afa028bc94c53f9326b/ctypes.picker.js#L8
Components.utils.import("resource://gre/modules/ctypes.jsm");
user32dll = ctypes.open('user32.dll');
var DWORD = ctypes.uint32_t;
var HANDLE = ctypes.size_t;
var HWND = HANDLE;
var BOOL = ctypes.bool;
var LPARAM = ctypes.size_t;