Skip to content

Instantly share code, notes, and snippets.

View germ13's full-sized avatar

juan serrano germ13

  • east los angeles
View GitHub Profile
public long nthPrime(int n)
{
// it's magic!
return f(n);
}

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert $1 -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 $2

Results

@germ13
germ13 / Emacs EShell
Last active August 29, 2015 14:10
Creates a buffer on the bottom 3rd of the frame. The buffers is an Emacs Eshell, that opens up to the current working directory of the current buffer. Borrowed from http://www.howardism.org/Technical/Emacs/eshell-fun.html
(defun eshell-here ()
"Opens up a new shell in the directory associated with the current buffer's file. The eshell is renamed to match that directory to make multiple eshell windows easier."
(interactive)
(let* ((parent (if (buffer-file-name)
(file-name-directory (buffer-file-name))
default-directory))
(height (/ (window-total-height) 3))
(name (car (last (split-string parent "/" t)))))
(split-window-vertically (- height))
(other-window 1)
@germ13
germ13 / vibrant-ink.el
Created December 27, 2014 09:19
vibrant-ink theme for .emacs
(deftheme vibrant-ink
"Emacs 24 theme based on Vibrant Ink for Textmate")
(custom-theme-set-faces
'vibrant-ink
'(default ((t (:background "#111111" :foreground "#ffffff"))))
'(cursor ((t (:background "#555577" :foreground "#ffffff"))))
'(region ((t (:background "#444444"))))
'(mode-line ((t (:background "#bfbfbf" :foreground "#000000"))))
'(mode-line-inactive ((t (:background "#e5e5e5" :foreground "#333333"))))
@germ13
germ13 / us.json
Created August 8, 2015 19:25
USA json from mbostock
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@germ13
germ13 / chrome_outline_elements.js
Created November 6, 2015 11:42
Within chrome dev tools, one can outline every element in a page.
[].forEach.call($$("*"),function(a){a.style.outline="1px solid #"+(~~(Math.random()*(1<<24))).toString(16)})
@germ13
germ13 / StickyNotes_FontRegEdit.reg
Created December 9, 2015 23:46
Windows "Sticky Notes" Registry edit to change default font. This one changes it to "Source Code Pro". Substitute accordingly.
REGEDIT4
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts]
"Segoe Print (TrueType)"="SourceCodePro-Regular.ttf"
"Segoe Print Bold (TrueType)"="SourceCodePro-Bold.ttf"
@germ13
germ13 / shell-game.clj
Created March 2, 2018 08:24
Codewars Kata: Shell Game (Clojure)
(ns the-shell-game)
;;https://www.codewars.com/kata/the-shell-game/clojure
(defn switch [location swap]
(cond (= location (first swap))
(last swap)
(= location (last swap))
(first swap)
:else
@germ13
germ13 / api.cs
Created March 23, 2018 05:56
api impersonation in c#
[Authorize]
public class ValuesController : ApiController
{
// GET api/values
public IEnumerable<string> Get()
{
WindowsPrincipal wp = (WindowsPrincipal)Thread.CurrentPrincipal;
WindowsIdentity wi = (WindowsIdentity)wp.Identity;
WindowsImpersonationContext wc = wi.Impersonate();
// this code accesses file system under
@germ13
germ13 / CreateToken.cs
Created April 10, 2018 06:41
Basic Symmetric
public IEnumerable<string> Get()
{
var user = Thread.CurrentPrincipal.Identity as WindowsIdentity;
// Define const Key this should be private secret key stored in some safe place
// This is a meaningles key of course
string key = "401b09eab3c013d4ca54922bb802bec8fd5318192b0a75f201d8b3727429090fb337591abd3e44453b954555b7a0812e1081c39b740293f765eae731f5a65ed1";
// Create Security key using private key above:
// not that latest version of JWT using Microsoft namespace instead of System