Instantly share code, notes, and snippets.

View cartesian.js
const input = 'abc'
const inputLength = 3
const powerSetSize = Math.pow(2, inputLength)
let result = []
for (let k = 0; k < powerSetSize; k++) {
let set = "";
let binaryDigits = k;
for (let j = 0; j < inputLength; j++) {
View .swift
func copyDatabaseIfNeeded() {
// Move database file from bundle to documents folder
let fileManager = FileManager.default
let documentsUrl = fileManager.urls(for: .documentDirectory,
in: .userDomainMask)
guard documentsUrl.count != 0 else {
return // Could not find documents URL
View AppMeasurement_Module_Media.js
function AppMeasurement_Module_Media(q) {
var b = this;
b.s = q;
q = window;
q.s_c_in || (q.s_c_il = [], q.s_c_in = 0);
b._il = q.s_c_il;
b._in = q.s_c_in;
b._il[b._in] = b;
q.s_c_in++;
b._c = "s_m";
View draggable.coffee
'use strict'
angular.module('ip')
.directive('draggable', ($document) ->
restrict: "EA"
link: (scope, element, attr) ->
pos_y = pos_x = drg_h = drg_w = 0
View gist:7372358
#!/usr/bin/perl
$|=1; #disable output buffering, this is necessary for proper output through pipe
my @rotors = ('EKMFLGDQVZNTOWYHXUSPAIBRCJ','AJDKSIRUXBLHWTMCQGZNPYFVOE','BDFHJLCPRTXVZNYEIWGAKMUSQO');
my $reflector = "YRUHQSLDPXNGOKMIEBFZCWVJAT";
my $key = "ABC";
sub li {
View gist:7372334
#!/usr/bin/env python
import string
_rotors = [ 'EKMFLGDQVZNTOWYHXUSPAIBRCJ',
'AJDKSIRUXBLHWTMCQGZNPYFVOE',
'BDFHJLCPRTXVZNYEIWGAKMUSQO'
]
_reflector = "YRUHQSLDPXNGOKMIEBFZCWVJAT"
_key = "ABC"
View gist:7372240
;'use strict';
enigma = (function() {
var _rotors = [ 'EKMFLGDQVZNTOWYHXUSPAIBRCJ',
'AJDKSIRUXBLHWTMCQGZNPYFVOE',
'BDFHJLCPRTXVZNYEIWGAKMUSQO'
]
, _reflector = "YRUHQSLDPXNGOKMIEBFZCWVJAT"
, _alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
View gist:7372208
#include <iostream>
#include <cstring>
using namespace std;
char alpha[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
char rotors[3][27] =
{
"EKMFLGDQVZNTOWYHXUSPAIBRCJ",
"AJDKSIRUXBLHWTMCQGZNPYFVOE",
"BDFHJLCPRTXVZNYEIWGAKMUSQO"
View Gemfile
gem 'angularjs-rails'
gem 'chart-js-rails'
View Bikes.m
#import "Bikes.h"
static sqlite3 *database = nil;
static sqlite3_stmt *detailStmt = nil;
@implementation Bikes
@synthesize BikesID, BikesName, price, isDirty, modelCount;
@synthesize modelName,modelID,modelType,groupCount,modelBrand;
@synthesize year,category,displacement,power,topSpeed,fuelConsumption,powerWeightRatio,naughtSixty,torque;