Skip to content

Instantly share code, notes, and snippets.

View sebcode's full-sized avatar

Sebastian Volland sebcode

View GitHub Profile
@sebcode
sebcode / ncursestest.cpp
Created April 24, 2011 20:48
quick&dirty example on how to use ncurses library in c++ to build a mutt-like user interface. build with g++ -lncurses ncursestest.cpp
#include <iostream>
#include <signal.h>
#include <ncurses.h>
#include <menu.h>
#include <string>
#include <unistd.h>
using namespace std;
#define SCREEN_MAIN 0
@sebcode
sebcode / mailcheck.py
Created April 25, 2011 13:38
script to display the number of new messages of an imap mailbox
import sys, imaplib
server = '...'
user = '...'
passwd = '...'
try:
s = imaplib.IMAP4_SSL(server)
s.login(user, passwd)
a, b = s.status('INBOX', '(MESSAGES UNSEEN)')
@sebcode
sebcode / fn.xsl
Created May 22, 2011 13:05
xslt function
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fn="http://exslt.org/functions"
xmlns:my="http://example.com"
exclude-result-prefixes="fn my">
<xsl:output method="xml"/>
<fn:function name="my:test">
<fn:result select="'result123'"/>
</fn:function>
@sebcode
sebcode / touchevents.html
Created May 22, 2011 13:14
example on how to handle mouse and touch events - http://sebcode.github.com/touchevents/
<!doctype html>
<title>touchevents</title>
<canvas id="canvas" width="500" height="300"></canvas>
<script>
function isTouchDevice() {
var el = document.createElement('div')
el.setAttribute('ongesturestart', 'return;')
@sebcode
sebcode / ssh-tunnel-mini-howto.md
Last active July 8, 2016 10:47
SSH Tunnel mini-HOWTO

SSH Tunnel Mini Howto

Local to Remote (-L)

-L Specifies that the given port on the local (client) host is to be forwarded to the given host and port on the remote side.

Use case: Make firewalled remote web server accessible from local machine

import Cocoa
let queue = Cocoa.OperationQueue()
let sema = DispatchSemaphore.init(value: 0)
queue.addOperation {
print("T1 Wait")
queue.addOperation {
@sebcode
sebcode / uploadFile.js
Created March 6, 2017 13:30
upload file with nodejs
const fs = require('fs')
const http = require('http')
const uploadFile = 'uploadMe.txt'
const req = http.request({
hostname: 'localhost',
port: 8080,
path: '/uploadtest',
method: 'PUT',
@sebcode
sebcode / openTermCommand.js
Created March 12, 2017 14:38
JXA: Programmatically open a new iTerm tab with a specified command
#!/usr/bin/osascript -l JavaScript
// Open a new iTerm tab with a specified command.
// Usage example: ./openTermCommand.js '/usr/local/bin/vim /tmp/test.txt'
function run(argv) {
const iTerm = Application('iTerm')
iTerm.includeStandardAdditions = true
iTerm.activate()
@sebcode
sebcode / tasks.js
Created March 17, 2017 18:28
nodejs: Execute multiple tasks in parallel
#!/usr/bin/env node
const async = require('async')
const numTasks = 10
const numParallel = 4
function doTask(i) {
console.log(`${i} start`)
return new Promise((resolve, reject) => {
@sebcode
sebcode / gist:4a43760ab4abaf078f987f1dd94d4178
Created April 6, 2017 18:17
Replace @autoBind decorator with class instance properties
// https://github.com/andreypopp/autobind-decorator
// https://github.com/facebook/codemod
// Example replacement:
// - @autobind onClick(e: SyntheticEvent) {
// + onClick = (e: SyntheticEvent) => {
codemod -m -d . --extensions js \
'@autobind\ ([a-zA-Z0-9]+)\(([^)]*)\)' \
'\1 = (\2) =>'