Skip to content

Instantly share code, notes, and snippets.

@jednano
jednano / EventEmitter.test.ts
Last active October 21, 2022 10:52
TypeScript Polling / Event Emitter
import { noop } from 'lodash';
import EventEmitter from './EventEmitter';
describe('EventEmitter class', () => {
describe('on()', () => {
it('subscribes to foo event with listener', () => {
const e = new EventEmitter();
e.on('foo', noop);
#!/bin/bash
set -e
CONTENTS=$(tesseract -c language_model_penalty_non_dict_word=0.8 --tessdata-dir /usr/local/share/tessdata/ "$1" stdout -l eng | xml esc)
hex=$((cat <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
@ibraheem4
ibraheem4 / postgres-brew.md
Last active October 14, 2024 11:59 — forked from sgnl/postgres-brew.md
Installing Postgres via Brew (OSX)

Installing Postgres via Brew

Pre-Reqs

Brew Package Manager

In your command-line run the following commands:

  1. brew doctor
  2. brew update
#I "../NeuralFish"
#load "NeuralFish_dev.fsx"
open NeuralFish.Types
open NeuralFish.Core
open NeuralFish.EvolutionChamber
open NeuralFish.Exporter
type SquareId = int
@chriseidhof
chriseidhof / tableviews.swift
Last active October 15, 2023 20:56
trySwift
import UIKit
// If you enjoyed this talk (video link will be up soon), then you might also enjoy our book Advanced Swift: http://www.objc.io/books/advanced-swift
struct Person {
let name: String
let city: String
}
let people = [
@boushley
boushley / MockVideoElement.js
Created January 6, 2016 17:37
Mock Video Element for use with dash.js -- Not quite complete but gets the basics functional
function createMockVideoElement() {
"use strict";
var video = {};
video.__mock_listeners = {};
video.__mock_progress = function(toProgress) {
var endProgressAt = video.currentTime + toProgress;
video.__mock_fire_event('play');
@larsparendt
larsparendt / extract-testflight.js
Created October 19, 2015 08:53
Extract TestFlight user email addresses from iTunes Connect
var text = ''; $('.col-email').each(function(index,el) { text = text + ($.trim($(el).text())+'\n' )}); var a = document.createElement("a"); var file = new Blob([text], {type: 'text/csv'}); a.href = URL.createObjectURL(file); a.download = name; a.click();
@TahaHachana
TahaHachana / ThrottlingAgent.fs
Last active August 26, 2020 05:00
An F# agent for throttling the number of concurrently executing asynchronous workflows. The default limit is 5 concurrent tasks. The agent also supports pausing and resuming work.
open System
open System.Collections.Concurrent
// Messages received by the throttling agent
type Message =
| Work
| Start of AsyncReplyChannel<unit>
| Pause
| Resume
| Quit
@jverkoey
jverkoey / NSNotificationCenterExtensions.swift
Last active January 24, 2016 22:19
NSNotificationCenter extension for safe Swift instance method support
/*
Copyright (c) 2011-present, NimbusKit. All rights reserved.
This source code is licensed under the BSD-style license found at http://nimbuskit.info/license
Extracted from NimbusKit: Swift Edition at https://github.com/nimbuskit/swift
*/
extension NSNotificationCenter {
/**
@minorbug
minorbug / timeago.swift
Created November 7, 2014 15:28
"Time ago" function for Swift (based on MatthewYork's DateTools for Objective-C)
func timeAgoSinceDate(date:NSDate, numericDates:Bool) -> String {
let calendar = NSCalendar.currentCalendar()
let unitFlags = NSCalendarUnit.CalendarUnitMinute | NSCalendarUnit.CalendarUnitHour | NSCalendarUnit.CalendarUnitDay | NSCalendarUnit.CalendarUnitWeekOfYear | NSCalendarUnit.CalendarUnitMonth | NSCalendarUnit.CalendarUnitYear | NSCalendarUnit.CalendarUnitSecond
let now = NSDate()
let earliest = now.earlierDate(date)
let latest = (earliest == now) ? date : now
let components:NSDateComponents = calendar.components(unitFlags, fromDate: earliest, toDate: latest, options: nil)
if (components.year >= 2) {
return "\(components.year) years ago"