Skip to content

Instantly share code, notes, and snippets.

View T1T4N's full-sized avatar
👽

Robert Armenski T1T4N

👽
View GitHub Profile
@pjlamb12
pjlamb12 / session.ts
Created April 26, 2016 15:40
NgZone After Auth0 Login
import {Injectable, NgZone} from 'angular2/core';
import {Http, Response, Headers} from 'angular2/http';
import {Router} from 'angular2/router';
import {tokenNotExpired} from 'angular2-jwt';
import 'rxjs/add/operator/map';
import {AppConfig} from '../services/config';
declare var Auth0Lock: any;
#!/bin/bash
#
# 4633c8a2a16a8e0428d253baafb76bbc18f29562390c84d1c85ba98865531a2b
CRYPTER="base64 -b 78"
HEADER="----BEGIN PGP MESSAGE----"
FOOTER="-----END PGP MESSAGE-----"
do_encryption() {
local plain="$1"
@jkp
jkp / qt5-base.rb
Created February 26, 2012 22:02
Formula to build a minimal qt5 base installation.
require 'formula'
require 'hardware'
class Qt5Base < Formula
homepage 'http://qt.nokia.com/'
head 'git://gitorious.org/qt/qtbase.git', :tag => 'e34ee3127043773a037bfd18a2d457d409032ee5'
keg_only 'For development purposes only'
def patches
#!/bin/bash
# Run this script just before you put the laptop in the bin for security scanning.
# You can add the seconds the laptop will be waiting before speaking. The default
# is waiting for 180 seconds (3 minutes).
# Switch to the login screen, effectively locking the screen.
function lockscreen() {
/System/Library/CoreServices/"Menu Extras"/User.menu/Contents/Resources/CGSession -suspend
}
@acg
acg / tsv2csv
Last active January 10, 2019 05:00
Convert tsv to csv with optional unescaping.
#!/usr/bin/env perl
use Text::CSV;
use Getopt::Long qw/ GetOptionsFromArray :config pass_through /;
use warnings;
use strict;
my $usage = "usage: $0 [-e] < file.tsv\n";
exit main( @ARGV );
@iamatypeofwalrus
iamatypeofwalrus / generate_ctags.md
Last active February 11, 2019 10:17
Generate ctags for Atom (or for any other reason) on Mac os X

Why?

Atom can automagically picks up any tags file in your current directory which enables you to:

  • shift+cmd+r search for any function in your project
  • alt+cmd+down GoTo a function declaration

How

Get brew if you don't already have it. Then:

brew install ctags

@adoc
adoc / pkcs7.py
Last active July 25, 2021 09:46
#pkcs7.py3: Implementation of PKCS #7 padding. Based on: http://japrogbits.blogspot.com/2011/02/using-encrypted-data-between-python-and.html
"""
Python implementation of PKCS #7 padding.
RFC 2315: PKCS#7 page 21
Some content-encryption algorithms assume the
input length is a multiple of k octets, where k > 1, and
let the application define a method for handling inputs
whose lengths are not a multiple of k octets. For such
algorithms, the method shall be to pad the input at the
trailing end with k - (l mod k) octets all having value k -
@algal
algal / HTTPBasicAuthenticationSessionTaskDelegate.swift
Last active October 6, 2021 07:33
HTTP Basic Authentication in iOS
/*
Everyone on Stack Overflow does HTTP Basic Authentication on iOS by manually
building the HTTP headers.
This amounts to re-implementing HTTP.
Why? The Cocoa Touch URL Loading System aleady knows HTTP, and you can
configure your URLSession to supply HTTP Basic Authentication credentials
like so.
@humblehacker
humblehacker / CVPixelBufferDeepCopy.swift
Last active February 13, 2022 20:35
Creates a deep copy of a CVPixelBuffer. Compatible with Swift 2.3.
extension CVPixelBuffer
{
/// Deep copy a CVPixelBuffer:
/// http://stackoverflow.com/questions/38335365/pulling-data-from-a-cmsamplebuffer-in-order-to-create-a-deep-copy
func copy() -> CVPixelBuffer
{
precondition(CFGetTypeID(self) == CVPixelBufferGetTypeID(), "copy() cannot be called on a non-CVPixelBuffer")
var _copy: CVPixelBuffer?
@soffes
soffes / UIColorExtension.swift
Created July 21, 2015 15:48 — forked from asarode/UIColorExtension.swift
Swift extension to get luma value of a UIColor
import UIKit
extension UIColor {
var luminance: CGFloat {
var red: CGFloat = 0
var green: CGFloat = 0
var blue: CGFloat = 0
getRed(&red, green: &green, blue: &blue, alpha: nil)