Skip to content

Instantly share code, notes, and snippets.

View elerch's full-sized avatar

Emil Lerch elerch

View GitHub Profile
@elerch
elerch / arduino_robot
Last active April 10, 2018 09:12 — forked from whyisjake/arduino_robot
Arduino Robot Code
/*
Original code by Nick Brenn
Modified by Marc de Vinck
Make Projects Arduino-based 4WD robot
http://makeprojects.com/Project/Build-your-own-Arduino-Controlled-Robot-/577/1
*/
#include <AFMotor.h>
AF_DCMotor motor1(1, MOTOR12_8KHZ);
AF_DCMotor motor2(2, MOTOR12_8KHZ);
AF_DCMotor motor3(3, MOTOR12_1KHZ);
javascript: (function ($) {
function load_script(src, callback) {
var s = document.createElement('script');
s.src = src;
s.onload = callback;
document.getElementsByTagName('head')[0].appendChild(s);
}
function invertElement() {
var colorProperties = ['color', 'background-color'];
@elerch
elerch / NodeFromCSharp.cs
Last active September 9, 2023 13:43
Using C# to host and communicate with node.js This proof of concept launches node.exe as a separate process, redirecting stdin/stdout. It simply calculates 2+2, then sends a process.exit() call after 10 seconds so the (.Net) app can complete (the suppressOut just gets node to output "undefined" instead of the full return value of setTimeout). Da…
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
@elerch
elerch / gist:7678872
Created November 27, 2013 16:39
Code to get a mocked HttpContext for unit testing
private HttpContext GetContext(IEnumerable<KeyValuePair<string,string>> postVariables)
{
postVariables = postVariables ?? Enumerable.Empty<KeyValuePair<string, string>>();
var context = new System.Web.HttpContext(
new System.Web.HttpRequest("", "http://tempuri.org", ""),
new HttpResponse(new StringWriter()));
var sessionContainer = new System.Web.SessionState.HttpSessionStateContainer("id", new System.Web.SessionState.SessionStateItemCollection(),
new HttpStaticObjectsCollection(), 10, true,
HttpCookieMode.AutoDetect,
System.Web.SessionState.SessionStateMode.InProc, false);
@elerch
elerch / Other
Last active August 29, 2015 14:06
/**
* State-based routing for AngularJS
* @version v0.2.10
* @link http://angular-ui.github.com/
* @license MIT License, http://www.opensource.org/licenses/MIT
*/
typeof module!="undefined"&&typeof exports!="undefined"&&module.exports===exports&&(module.exports="ui.router"),function(n,t,i){"use strict";function l(n,t){return e(new(e(function(){},{prototype:n})),t)}function p(n){return f(arguments,function(t){t!==n&&f(t,function(t,i){n.hasOwnProperty(i)||(n[i]=t)})}),n}function ht(n,t){var r=[];for(var i in n.path){if(n.path[i]!==t.path[i])break;r.push(n.path[i])}return r}function ct(n,t){if(Array.prototype.indexOf)return n.indexOf(t,Number(arguments[2])||0);var r=n.length>>>0,i=Number(arguments[2])||0;for(i=i<0?Math.ceil(i):Math.floor(i),i<0&&(i+=r);i<r;i++)if(i in n&&n[i]===t)return i;return-1}function w(n,t,i,r){var o=ht(i,r),u,h={},c=[],s,f;for(s in o)if(o[s].params&&o[s].params.length){u=o[s].params;for(f in u)ct(c,u[f])>=0||(c.push(u[f]),h[u[f]]=n[u[f]])}return e({},h,t)}function b(n,t){var i={};ret
{
"version":3,
"file":"Other",
"lineCount":20,
"mappings":";;;;;;AAQI,OAAOA,MAAO,EAAI,WAAY,EAAG,OAAOC,OAAQ,EAAI,WAAY,EAAGD,MAAMC,QAAS,GAAIA,O,GACxFD,MAAMC,QAAS,CAAE,YAAW,CAG7B,QAAS,CAACC,CAAM,CAAEC,CAAO,CAAEC,CAAlB,CAA6B,CAGvC,Y,CAWAC,SAASA,CAAO,CAACC,CAAM,CAAEC,CAAT,CAAgB,CAC9B,OAAOC,CAAM,CAAC,IAAKA,CAAM,CAAC,QAAQ,CAAA,CAAG,EAAE,CAAE,CAAE,SAAS,CAAEF,CAAb,CAAhB,EAAyC,CAAEC,CAAvD,CADiB,CAIhCE,SAASA,CAAK,CAACC,CAAD,CAAM,CAQlB,OAPAC,CAAO,CAACC,SAAS,CAAE,QAAQ,CAACC,CAAD,CAAM,CAC3BA,CAAI,GAAIH,C,EACVC,CAAO,CAACE,CAAG,CAAE,QAAQ,CAACC,CAAK,CAAEC,CAAR,CAAa,CAC3BL,CAAGM,eAAe,CAACD,CAAD,C,GAAOL,CAAI,CAAAK,CAAA,CAAK,CAAED,EADT,CAA3B,CAFsB,CAA1B,CAML,CACKJ,CARW,CAkBpBO,SAASA,EAAS,CAACC,CAAK,CAAEC,CAAR,CAAgB,CAChC,IAAIC,EAAO,CAAA,CAAE,CAEb,IAAS,IAAAC,EAAE,GAAGH,CAAKE,KAAnB,CAA0B,CACxB,GAAIF,CAAKE,KAAM,CAAAC,CAAA,CAAG,GAAIF,CAAMC,KAAM,CAAAC,CAAA,EAAI,KAAK,CAC3CD,CAAIE,KAAK,CAACJ,CAAKE,KAAM,CAAAC,CAAA,CAAZ,CAFe,CAI1B,OAAOD,CAPyB,CAmClCG,SAASA,EAAW,CAACC,CAAK,CAAEV,CAAR,CAAe,CACjC,GAAIW,KAAKC,UAAUC,SACjB,OAAOH,CAAKG,QAAQ,CAA
@elerch
elerch / arch-usb-uefi.md
Last active January 26, 2024 22:20
Installation of Arch Linux on a USB stick with UEFI and legacy BIOS Support

Our goal here is to have one USB stick to rule them all. Objectives:

  • We want a full system - not a live CD
  • We want to boot this system on a Macbook Pro (requires UEFI)
  • We want to boot this system on a Acer C720 Chromebook (requires Legacy BIOS support)
  • We want the system "functional"

The last bullet is subject to interpretation, but I'm defining functional as:

  • X Windows works (with LXDE)
@elerch
elerch / AWSTruisms.md
Last active March 21, 2017 18:30
AWS Truisms

Always do

  • Avoid using root credentials
  • Turn on cloudtrail
  • Turn on config recorder

Always prefer

@elerch
elerch / sshconfig-stub
Created January 26, 2017 00:42
Stub for ~/.ssh/config
# Sane security defaults for SSH clients. Disables everything old and nasty.
# Explanation: http://mochtu.de/2015/01/06/securing-ssh-connections/
# Background information: https://stribika.github.io/2015/01/04/secure-secure-shell.html
# OSX Users: consider updating your openssh version, or you might see an error.
Host *
KexAlgorithms curve25519-sha256@libssh.org,diffie-hellman-group-exchange-sha256
# delete diffie-hellman-group-exchange-sha1
Ciphers chacha20-poly1305@openssh.com,aes256-ctr,aes192-ctr,aes128-ctr
MACs hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-ripemd160-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-512,hmac-sha2-256,hmac-ripemd160,umac-128@openssh.com
@elerch
elerch / gist:74cc32ef31048778f10bb10110e59c42
Created January 27, 2017 23:44 — forked from agriffis/gist:2481292
.bashrc.virtualenvwrapper
# Dynamically load virtualenvwrapper functions to reduce shell startup
# time.
#
# Copyright 2012 Aron Griffis <aron@arongriffis.com>
# Released under the GNU GPL v3
#######################################################################
# Python virtualenvwrapper loads really slowly, so load it on demand.
if [[ $(type -t workon) != function ]]; then
virtualenv_funcs=( workon deactivate mkvirtualenv )