Skip to content

Instantly share code, notes, and snippets.

View sbarski's full-sized avatar

Peter Sbarski sbarski

View GitHub Profile
const moment = require('moment');
const momentDurationFormatSetup = require('moment-duration-format');
function processItems(structure) {
const maxSentenceLength = 32;
const maxParagraphLength = 64; //we want to keep this to 64 or less (per line)
let srtTranscription = "WEBVTT\n\n";
let numberOfChars = 0;
let sentence = "";
@sbarski
sbarski / Recursive Zip
Created October 10, 2016 01:30
Recursive Zip
zip -r foo.zip foo -x "*.DS_Store"
@sbarski
sbarski / ultimate-ut-cheat-sheet.md
Created April 23, 2016 13:13 — forked from yoavniran/ultimate-ut-cheat-sheet.md
The Ultimate Unit Testing Cheat-sheet For Mocha, Chai and Sinon

The Ultimate Unit Testing Cheat-sheet

For Mocha, Chai and Sinon

using mocha/chai/sinon for node.js unit-tests? check out my utility: mocha-stirrer to easily reuse test components and mock require dependencies


@sbarski
sbarski / gist:a84f60a2317b84138d40
Last active March 17, 2016 00:06
Git tips and tricks
**Automatically delete orig files after merge**
git config --global mergetool.keepBackup false
**Interactive git clean**
git clean -i
**All git commits not pushed**
git cherry -v
**How to grep (search) committed code in the git history?**
@sbarski
sbarski / index.js
Last active January 5, 2023 11:10
A Lambda function that creates and submits an Elastic Transcoder job after being invoked by an S3 bucket
'use strict';
var AWS = require('aws-sdk');
var s3 = new AWS.S3({
apiVersion: '2012-09-25'
});
var eltr = new AWS.ElasticTranscoder({
apiVersion: '2012-09-25',
region: 'us-east-1'
});
@sbarski
sbarski / azure-deployment.ps1
Last active October 29, 2020 14:59
How to deploy to Azure Cloud Service via Powershell
param([string]$publishSettingsFileLocation, [string]$azureSubscriptionName, [string]$storageAccount, [string]$packagePath, [string]$packageName, [string]$containerName, [string]$serviceName, [string]$configPath, [Int32]$instancePollLimit = 1200, [Int32]$instancePollRate = 60, [string]$removeStagingInstance)
#The old publish settings file - use Get-AzurePublishSettingsFile to https://windows.azure.com/download/publishprofile.aspx to get the file
Write-Host "publishSettingsFileLocation is $publishSettingsFileLocation"
#The azure subscription name related to the account, eg. "Window Azure MSDN - Visual Studio Premium"
Write-Host "azureSubscriptionName is $azureSubscriptionName"
#The storage account where to upload the package. It must exist. E.g. mystorageaccountforupload
Write-Host "storageAccount is $storageAccount"
@sbarski
sbarski / gist:5a9e94632ff68e5dbd58
Created August 13, 2014 02:58
Schema for ASP.NET Identity Model 2.0
CREATE TABLE [dbo].[AspNetUsers](
[Id] [nvarchar](128) NOT NULL,
[Email] [nvarchar](256) NULL,
[EmailConfirmed] [bit] NOT NULL,
[PasswordHash] [nvarchar](max) NULL,
[SecurityStamp] [nvarchar](max) NULL,
[PhoneNumber] [nvarchar](max) NULL,
[PhoneNumberConfirmed] [bit] NOT NULL,
[TwoFactorEnabled] [bit] NOT NULL,
[LockoutEndDateUtc] [datetime] NULL,
//Slow Implementation
func fib1(x: Int) -> Int {
return x < 2 ? x : fib1(x - 1) + fib1(x - 2)
}
let m = fib1(5)
//Fib Trivial Memoization
var memoizeDict = Dictionary<Int, Double>()
@sbarski
sbarski / Playing swift
Created June 17, 2014 10:02
Playing swift
// Playground - noun: a place where people can play
operator infix |> {
associativity left
}
operator infix <| {
associativity right
}
@sbarski
sbarski / gist:8518136
Created January 20, 2014 10:45
F# and OpenTK together This sample is adopted from the C# example in http://www.opentk.com/doc/chapter/0
// Released to the public domain. Use, modify and relicense at will.
//#r "OpenTK.dll"
open System
open System.Drawing
open System.Collections.Generic
open OpenTK
open OpenTK.Graphics
open OpenTK.Graphics.OpenGL