Skip to content

Instantly share code, notes, and snippets.

@neovov
neovov / gist:4729149
Created February 7, 2013 07:17
Silverlight method to nuke itself (just for the LOL)
[ScriptableMember]
public void nuke() {
HtmlPage.Plugin.Parent.RemoveChild( HtmlPage.plugin );
} // end of nuke()
@neovov
neovov / VMWare
Created April 12, 2013 13:50
A list of shell commands to command a virtual machine (launching it, opening IE with a website, getting IE's PID, killing it and shut down the VM)
# Start the virtual machine
/Applications/VMware Fusion.app/Contents/Library $ ./vmrun -gu <username> -gp <password> start <VMX file> nogui
# -gu: Virtual's machine username
# -gp: Virtual's machine password
# <VMX file>: ~/Documents/Virtual Machines.localized/IE8.vmwarevm/Windows XP Professionnel.vmx
# nogui: Work headless
# Launch IE on the virtual machine and go to a given page
/Applications/VMware Fusion.app/Contents/Library $ ./vmrun -gu <username> -gp <password> runScriptInGuest <VMX file> -noWait -activeWindow "" "\"C:\Program Files\Internet Explorer\iexplore.exe\" http://google.fr/"
# Doesn't work :(
$ /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app/Contents/MacOS/iPhone\ Simulator -SimulateApplication /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.1.sdk/Applications/MobileSafari.app/MobileSafari -u http://google.fr
# Works :) !
$ ios-sim launch /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/S
DKs/iPhoneSimulator6.1.sdk/Applications/MobileSafari.app --args -u http://google.fr
# But: brew install ios-sim :/
@neovov
neovov / Spotlight command line
Created April 12, 2013 15:06
Some command lines to use Spotlight and find some files
# Display file's metadata
$ mdls <file>
# Firefox (but not Aurora)
$ mdfind "kMDItemKind == 'Application' && kMDItemDisplayName == '*Firefox*'"
# Firefox Aurora
$ mdfind "kMDItemKind == 'Application' && kMDItemDisplayName == '*Aurora*'"
# Chrome & Chrome Canary
@neovov
neovov / Les formats de données
Last active December 20, 2015 02:49
Modification du tableau listant les bibliothèques permettant de parser les formats de données (http://www.la-grange.net/2013/07/04/data-formats)
| format | python | php | ruby | javascript |
| -------------------------------------------- |:---------------------------:|:-----------------:|:----:| ----------------:|
| Internet Message Format (email) | email.parser | ? | ? | ? |
| JSON | json | natif (PHP 5.2) | ? | natif (ES5) |
| Base64 | base64 | natif (PHP 4) | ? | natif (?) |
| Multipurpose Internet Mail Extensions (MIME) | quopri | natif (PHP 5.3) | ? | mime (Node.JS) |
| XML | elementtree | libxml (natif) | ? | natif |
| XPath | elementtree (partiel) | libxml (natif) | ? | natif |
| RDF/XML
@neovov
neovov / gist:6634959
Last active December 23, 2015 12:19
Test if the browser support the transitionend event
var transitionend;
// Test for transitionend event
(function() {
if (!window.addEventListener) {
return;
}
var div = document.createElement("div");
function handler(e) {
@neovov
neovov / deezer-web-streams-1.js
Created February 9, 2017 15:24
ReadableStream
new ReadableStream({
start(controller) {
return fetch('http://…').then(response => {
// In browsers supporting Web Streams, Fetch's response's body is a ReadableStream
// Otherwise, in order to stream the response you will have to request some bytes ranges manually
// Get a reader on the incoming data
const reader = response.body.getReader();
// Read a chunk
@neovov
neovov / deezer-web-streams-2.js
Created February 9, 2017 15:26
WritableStream
const source = new ReadableStream({…}); // As seen above
const destination = new WritableStream({
start(controller) {
// Return a promise to signal the construction is asynchronous
return new Promise(resolve => {
const source = new MediaSource();
// Mark the WritableStream as ready when the source is open
source.addEventListener('sourceopen', () => {
this.buffer = source.addSourceBuffer('audio/mpeg');
@neovov
neovov / deezer-web-streams-3.js
Created February 9, 2017 15:28
ReadableStream piping
// Read a chunk
reader.read().then(function process(result) {
if (result.done) {
return controller.close();
}
console.log('Reading', result.value.length, 'bytes');
controller.enqueue(result.value);
return reader.read().then(process); // Continue reading
@neovov
neovov / deezer-web-streams-4.js
Created February 13, 2017 17:13
TransformStream
const source = new ReadableStream({…}); // As seen above
const destination = new WritableStream({…}); // As seen above
const transformer = new TransformStream({
transform(chunk, controller) {
// Simply increment each bytes
const transformed = chunk.map(value => Math.min(value + 1, 255));
// Enqueue the transformed data
controller.enqueue(transformed);