Skip to content

Instantly share code, notes, and snippets.

@thinkricardo
thinkricardo / .prettierignore
Last active January 11, 2024 01:08
Configure prettier whitelist using .prettierignore
# ignore all files
*
# include all folders
!**/
# include files to format
!*.js
!*.json
!*.scss
@stefancocora
stefancocora / vpn-openconnect-connect-to-cisco-anyconnect.md
Created September 25, 2017 08:48
Split tunneling with openconnect - A guide on how to use openconnect to establish a vpn connection to an enterprise cisco anyconnect vpn endpoint with client side routing.

Introduction

The purpose of this short howto is to show you how to:

  • use openconnect [1] to connect to an enterprise cisco anyconnect endpoint
  • whilst minimizing the amount of traffic that your route through the vpn connection

Usually VPN administrators will puth the default route to the users, so that all user traffic is routed through the vpn connection. This is to address the various security concerns around compromised user computers bridging external internet traffic into the secure VPN network.

While the VPN administrator can push routes to the clients, the client can ignore these default routes and establish client side routing so that only the required A.B.C.D/E network is routed through the VPN. All other traffic will still use the clients default route and default outbound internet connection.

@abhishekjairath
abhishekjairath / nodobjc-macOS-notification-listener.js
Created March 12, 2017 06:33
Using 'nodobjc' a nodeJS->ObjectveC bridge to listen to distributed notification centre of macOS/OSX.
var $ = require('nodobjc')
$.framework('Foundation')
$.framework('AppKit')
var GetSongs = $.NSObject.extend('Delegate');
GetSongs.addMethod('getMySongs:', 'v@:@', function(self, _cmd, notif){
var userInfo = notif('userInfo')
var keys = userInfo('keyEnumerator');
@p120ph37
p120ph37 / vpn.expect
Last active December 19, 2021 23:08
Expect script to connect to an AnyConnect VPN server on OSX using only oathtool and openconnect (not the Cisco AnyConnect client)
!/usr/bin/expect -f
set timeout 30
log_user 0
puts stderr "Generating OTP"
spawn oathtool --totp YOUR_SECRET_KEY_HERE
expect -re \\d+
set otp $expect_out(0,string)
puts stderr "Connecting to VPN server $server"
@dkordik
dkordik / fightthefuture.js
Last active December 28, 2015 13:19
Better Meteor async. Man, futures can be confusing! This is how I clean things up a little bit in my actual methods.
var Future = Npm.require('fibers/future'); //npm install fibers
var async = function (callback) { //let's tuck away some of the nastyness in here
var future = new Future();
var returnFunc = function () {
future["return"].apply(future, arguments);
}
callback(returnFunc);
@dkordik
dkordik / bubble_error_events.js
Created October 3, 2013 20:02
Image error events don't bubble, (see http://www.w3.org/TR/DOM-Level-3-Events/#event-type-error ) which can be pretty annoying when you're trying to handle them with any modern event-delegation-y technique. This uses event capturing on supported browsers to trigger a standard bubble-friendly event on the element in question, so you can handle th…
//image error events don't bubble, so we use
// native event capturing, where supported
if (document.addEventListener && !document.bubbleErrors) {
document.addEventListener('error', function (event) {
jQuery(event.target).trigger(event); //bubble it ourselves!
}, true); //true = use event capturing (not bubbling)
document.bubbleErrors = true;
}
@wacko
wacko / gist:5577187
Last active January 6, 2024 07:31
SSH between Mac OS X host and Virtual Box guest

On Mac OS (host):

Shutdown your VM and do:

VirtualBox > Settings > Network > Add (you will get vboxnet0)

On a terminal ifconfig will show you new interface vboxnet0

VM's Settings > System > check "Enable I/O APIC." VM's Settings > Network > Adapter 2 > host-only vboxnet0

@jagtesh
jagtesh / split_tunneling.md
Created May 7, 2013 09:06
Split Tunneling tutorial - with openconnect (tested, works with Cisco AnyConnect VPN) Source: http://lists.unix-ag.uni-kl.de/pipermail/vpnc-devel/2009-February/002990.html

Table of Contents

  1. DISCLAIMER 2. Status 3. Introduction 4. Security issues 5. DNS
@possibilities
possibilities / meteor-async.md
Created August 23, 2012 22:53
Meteor Async Guide

From Meteor's documentation:

In Meteor, your server code runs in a single thread per request, not in the asynchronous callback style typical of Node. We find the linear execution model a better fit for the typical server code in a Meteor application.

This guide serves as a mini-tour of tools, trix and patterns that can be used to run async code in Meteor.

Basic async

Sometimes we need to run async code in Meteor.methods. For this we create a Future to block until the async code has finished. This pattern can be seen all over Meteor's own codebase: