Skip to content

Instantly share code, notes, and snippets.

View anaisbetts's full-sized avatar

Ani Betts anaisbetts

View GitHub Profile
@anaisbetts
anaisbetts / jobber.cpp
Created January 17, 2016 07:59
Collect a process into a job group, then let you kill it via writing to a pipe
// Jobber.cpp : Defines the entry point for the application.
//
#include "stdafx.h"
#include "Jobber.h"
int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
_In_opt_ HINSTANCE hPrevInstance,
_In_ LPWSTR lpCmdLine,
_In_ int nCmdShow)
import rx from 'rx';
import requestRx from '../request-rx';
import connect from 'connect';
import semver from 'semver';
import _ from 'lodash';
import http from 'http';
import logger from '../logger';
// Public: This class handles updates via Squirrel for Mac (aka the 'auto-updater'
// module in Atom Shell). This class is complicated because we create a fake update
@anaisbetts
anaisbetts / example.html
Created December 22, 2015 17:06
ExecuteJavaScript returning a result
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Electron boilerplate</title>
<link rel="stylesheet" href="index.css">
<script>
window.foo = {};
window.foo.bar = {
baz: function(a,b) {
async convertBlobToBuffer(blob) {
let fileReader = new FileReader();
// Listen to when reading is finished and
// run the callback with a buffer.
let loadEnd = new Promise((resolve, reject) => {
fileReader.addEventListener("loadend", (ev) => {
if (ev.error) {
reject(ev.error);
}
@anaisbetts
anaisbetts / auto-ssp.js
Created November 3, 2015 19:05
Auto-generate HTTP/2 push manifest, and use it with express.static
import path from 'path';
import _ from 'lodash';
import generatePushManifest from './generate-push-manifest';
export default function autoPush(fileRoot) {
const realRoot = path.resolve(fileRoot);
let pushManifest = generatePushManifest(realRoot);
return (res, filePath) => {
@anaisbetts
anaisbetts / slack-login.html
Created October 26, 2015 05:26
RxJS + Polymer
<dom-module id="slack-login">
<style>
:host {
display: block;
}
#card {
min-width: 500px;
}
@anaisbetts
anaisbetts / copstache.cs
Created October 14, 2015 20:32
It's like a crappy version of mustache
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security;
using System.Text;
using System.Threading.Tasks;
namespace Squirrel.Update
{
public static class CopStache
@anaisbetts
anaisbetts / example.js
Created September 19, 2015 00:14
Cool tricks with ES6 templated strings
import {p} from './get-path';
console.log(p`${'userDesktop'}/MyApp`);
// On Windows
>> C:\Users\TheUser\Desktop\MyApp
// On OS X
>> /Users/TheUser/Desktop/MyApp
@anaisbetts
anaisbetts / TrayStateChanger.cs
Created September 15, 2015 04:19
Call secret Explorer API to change tray state
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Interop;
namespace SlackNotifier
{
@anaisbetts
anaisbetts / rebaseall.ps1
Created September 14, 2015 17:57
rebaseall but for GitHub for Windows PGit
gcm git | %{$_.Path.Replace("\cmd\git.exe", "\bin")} | cd
ls *.dll | %{.\rebase.exe -d -b 0x70000000 -o 0x10000 $_}