Skip to content

Instantly share code, notes, and snippets.

$(() => {
if (location.hash) {
$("a[href='" + location.hash + "']").tab("show"); // go to tab when hash is present in the url
}
$(document.body).on("click", "a[data-toggle]", function(event) {
location.hash = this.getAttribute("href"); // add hash to url when change tab
});
});
$(window).on("popstate", function() { // make history navigation aware of anchor
var anchor = location.hash || $("a[data-toggle='tab']").first().attr("href");
require 'openssl'
KEY = '1'*32
IV = '1'*12
ALG = 'aes-256-gcm'
def bin2hex(s)
s.unpack('H*').first
end
require 'openssl'
require "base64"
KEY = '1'*32
IV = '1'*16
ALG = 'aes-256-cbc'
def encrypt(plaintext)
cipher = OpenSSL::Cipher.new(ALG)
cipher.encrypt
@masciugo
masciugo / node_env.py
Created August 10, 2017 14:44 — forked from joesepi/node_env.py
Updated python script to manage nvm and ST3 pathing for OSX
# Sublime package NVM node path configuration
# Save this file in:
# ~/Library/Application\ Support/Sublime\ Text\ 3/Packages/node_env.py
import os
os.environ["PATH"] = "/Users/YOUR_USERNAME/.nvm/v0.10.26/bin:/Users/cranemes/.nvm/v0.10.26/lib:/Users/YOUR_USERNAME/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
print("PATH=" + os.environ["PATH"])
@masciugo
masciugo / fennel_accounts_test.js
Created May 18, 2017 13:12
fennel-dev test file
import { assert } from 'chai';
import co from 'co';
import * as dav from '../../lib';
suite('accounts', function() {
suite('#create', function() {
let xhr;
setup(function() {
import DS from 'ember-data';
import Ember from 'ember';
export function initialize(/* container, application */) {
DS.Model.reopen({
saveOriginalRelations: function() {
this.originalRelations = {};
@masciugo
masciugo / test.rb
Last active August 29, 2015 14:26
boilerplate code for a ruby script with bundler/inline
begin
require 'bundler/inline'
rescue LoadError => e
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
raise e
end
gemfile(true) do
source 'https://rubygems.org'
gem 'rails', github: 'rails/rails'
@masciugo
masciugo / download_quotidie
Last active August 29, 2015 14:22
download quotidie
#!/usr/bin/env ruby
require 'mechanize'
require 'open-uri'
require 'byebug'
class Zeitung
attr_accessor :uri
attr_reader :final_name, :regexp, :move
def initialize(final_name, regexp, move=false)
@masciugo
masciugo / index.html
Last active August 29, 2015 14:21
Replace div with CSS only. JS Bin// source http://jsbin.com/nazase
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
<style id="jsbin-css">
.switch {
position: relative;
}
.switch:hover .replace {
@masciugo
masciugo / script_skeleton
Created May 13, 2015 09:08
A skeleton for a ruby script
#!/usr/bin/env ruby
require 'rubygems'
require 'fastercsv'
require 'ruby-debug'
require 'logger'
log = Logger.new(STDOUT, File::WRONLY | File::APPEND | File::CREAT)
log.level = Logger::DEBUG
log.datetime_format = "%Y-%m-%d %H:%M:%S"