Skip to content

Instantly share code, notes, and snippets.

View anaisbetts's full-sized avatar

Ani Betts anaisbetts

View GitHub Profile
@anaisbetts
anaisbetts / slack-cron-job-debian.sh
Created September 8, 2015 03:54
Cron script to add debian / rpm repo
#!/bin/sh
#
# Copyright (c) 2015 Slack Technologies. Original version from Google Chrome,
# license is below.
#
# Copyright (c) 2009 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
#
# It creates the repository configuration file for package updates, and it
const rx = require('rx');
const request = require('../request-rx');
const path = require('path');
const fs = require('fs');
const spawn = require('../spawn-rx');
const _ = require('lodash');
const semver = require('semver');
const {is64BitOperatingSystem} = require('../native-interop');
const logger = require('./logger').init(__filename);
@anaisbetts
anaisbetts / AccentColors.cs
Created August 18, 2015 17:54
Render the accent background of a Windows Store-style icon
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media;
// https://raw.githubusercontent.com/maxtruxa/AccentColors/master/AccentColors/AccentColor.cs
@anaisbetts
anaisbetts / example-component-spec.js
Created August 13, 2015 23:48
ES6 + Polymer + Electron node modules
import LoadingScreen from '../../src/renderer-ng/loading-screen/loading-screen.html';
describe('The Loading Screen', function() {
beforeEach(function() {
this.fixture = new LoadingScreen();
this.fixture.id = 'fixture';
document.body.appendChild(this.fixture);
});
afterEach(function() {
@anaisbetts
anaisbetts / shasums.sh
Created August 5, 2015 19:43
Slack 1.1.7 SHA1 hashes
$ ls slack*1.1.7* | xargs -L1 shasum
d7e238a1c029a5dbe7d989a01ceec9076d115107 slack-1.1.7-0.1.fc21.x86_64.rpm
a23ba0ced430ab633058c0d0989ac07d94978899 slack-1.1.7-amd64.deb
53d3160656763598a1ed51f07802eca8bc6f9af2 slack-1.1.7-i386.deb
@anaisbetts
anaisbetts / request-rx.js
Created February 18, 2015 06:36
Rx'ification of request
'use 6to5';
const rx = require('rx');
const request = require('request');
let wrapMethodInRx = (method) => {
return function(...args) {
return rx.Observable.create((subj) => {
// Push the callback as the last parameter
args.push((err, resp, body) => {
Sampling process 14518 for 3 seconds with 1 millisecond of run time between samples
Sampling completed, processing symbols...
Analysis of sampling GitHub (pid 14518) every 1 millisecond
Process: GitHub [14518]
Path: /Applications/GitHub.app/Contents/MacOS/GitHub
Load Address: 0x1039c4000
Identifier: com.github.GitHub
Version: Aussie Rules (197.1)
Code Type: X86-64
Parent Process: ??? [1]
@anaisbetts
anaisbetts / native-interop.coffee
Last active August 29, 2015 14:14
node-ffi in Atom Shell
ref = require 'ref-atom-shell'
ffi = require 'ffi-atom-shell'
intPtr = ref.refType(ref.types.int32)
shell32 = ffi.Library('shell32', {
'SHQueryUserNotificationState': [ 'int', [ intPtr ] ]
})
logger = null
@anaisbetts
anaisbetts / example.js
Created January 27, 2015 23:04
Observe object and all of its children
someHash = {}
>>> Object {}
observeAll(someHash).subscribe(function(x) { console.log(JSON.stringify(x)) })
>>> AutoDetachObserver {isStopped: false, observer: AnonymousObserver, m: BooleanDisposable, constructor: function, next: function…}
someHash.foo = 'bar'
>>> VM427:2 [{"type":"add","object":{"foo":"bar"},"name":"foo"}]
>>> "bar"
@anaisbetts
anaisbetts / analytics.js
Created January 7, 2015 20:47
Google Analytics in Atom Shell
// Pretend that cookies work
(function (document) {
var cookies = {};
document.__defineGetter__('cookie', function () {
var output = [];
for (var cookieName in cookies) {
output.push(cookieName + "=" + cookies[cookieName]);
}
return output.join(";");
});