Skip to content

Instantly share code, notes, and snippets.

View yene's full-sized avatar
🏅
Best Developer of the Day

Yannick yene

🏅
Best Developer of the Day
View GitHub Profile
@yene
yene / mirror.sh
Last active August 29, 2015 14:02
#!/bin/bash
/usr/bin/ssh git@op6 expand > repos.txt
myarr=($(awk '{print $NF}' repos.txt))
counter=0
for i in "${myarr[@]}"
do
counter=$(($counter+1))
if [ "$counter" -eq 1 ] || [ "$counter" -eq 2 ]
then
@yene
yene / index.php
Created November 26, 2014 13:23
show SBB delay on a hardcoded connection
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>SBB Verspätungen</title>
<!-- Normalize.css is a customisable CSS file that makes browsers render all elements more consistently and in line with modern standards. -->
<link rel="stylesheet" media="screen" href="https://raw.github.com/necolas/normalize.css/master/normalize.css">
<style>
@yene
yene / face.php
Created November 27, 2014 12:55
PHP mark faces in images
<?php
if (extension_loaded("facedetect")) {
echo "facedetect extension loaded \n";
} else {
echo "facedetect extension not loaded, can't do face detect \n";
}
$file = "haarcascade_frontalface_alt.xml";
@yene
yene / pasteboard.go
Created January 15, 2015 14:25
call pasteboard on mac os x from go
package main
/*
#cgo CFLAGS: -x objective-c
#cgo LDFLAGS: -framework Cocoa
#import <Cocoa/Cocoa.h>
int
StartApp(void) {
[NSAutoreleasePool new];
@yene
yene / deploy.sh
Created April 9, 2015 18:43
FTP upload master branch
#!/bin/bash
git clone -b master --single-branch . temp
cd temp
find . -type f -exec curl -u USER:PASSWORD --ftp-create-dirs -T {} ftp://server/path/to/www/{} \;
rm -rf temp
@yene
yene / now playing.scpt
Created April 18, 2015 16:56
Write current Spotify song to file for OBS
set oldTrack to ""
set current_user to do shell script "whoami"
set the_file to "/Users/" & current_user & "/NowPlaying.txt"
do shell script "touch " & POSIX path of the_file -- create file
repeat
if application "Spotify" is not running then
say "spotify is not running"
@yene
yene / gist:f7c625b8e77cf8df129b
Last active August 29, 2015 14:20
saving and restoring NSDate with NSUserDefaults
var startTime: NSDate
let defaults = NSUserDefaults.standardUserDefaults()
defaults.setObject(startTime, forKey: "startTime")
// ...
let defaults = NSUserDefaults.standardUserDefaults()
if let object: AnyObject = defaults.objectForKey("startTime") {
startTime = object as! NSDate
@yene
yene / netstat.c
Created June 24, 2015 09:02
Showing OS traffic
/*
* Print interface statistics in bytes per second
*
* Parameters:
* -t # Time interval to compute, default 2 seconds
* -i <ifname> Interface name, defaults to 'en0'
* -s Print raw stats
*
* Output: Two numbers separated by a space. First value is input bytes per
* second. Second value is output bytes per second
@yene
yene / folderaction.js
Created June 25, 2015 17:28
Folder Action that copies Dropbox Public URL to clipboard
function run(input, parameters) {
dropboxURL = "https://dl.dropboxusercontent.com/u/XXXXXXX/FOLDER/";
currentApp = Application.currentApplication()
currentApp.includeStandardAdditions = true
inFile = input.toString()
inFile = basename(inFile)
inFile = encodeURIComponent(inFile)
//currentApp.displayAlert(dropboxURL + inFile);
currentApp.setTheClipboardTo(dropboxURL + inFile)
@yene
yene / tm-check.js
Last active August 29, 2015 14:25
Check when the last Time Machine Backup was and display notification
// use it in calender: http://apple.stackexchange.com/a/59265/14030
app = Application.currentApplication()
app.includeStandardAdditions = true
ObjC.import('Cocoa')
dict = $.NSDictionary.dictionaryWithContentsOfFile('/Library/Preferences/com.apple.TimeMachine.plist')
firstItem = dict.valueForKey('Destinations').firstObject
lastBackup = firstItem.valueForKey('SnapshotDates').lastObject
diff = lastBackup.timeIntervalSinceNow // in seconds