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
//
// MyApplication.m
// IdleTimer
//
// Created by Yannick Weiss on 21.06.10.
// Copyright 2010 __MyCompanyName__. All rights reserved.
//
#import "MyApplication.h"
#import "IdleTimerContainer.h"
@interface MyApplication : NSApplication {
NSTimer *idleTimer;
NSMutableArray *idleTimerObjects;
unsigned int elapsedSeconds;
}
- (void)sendEvent:(NSEvent *)anEvent;
- (void)timerInvocation;
- (BOOL)isUser5SecondsIdle;
- (void)finishIdle;
dispatch_queue_t queue = dispatch_queue_create(“com.app.task”,NULL)
dispatch_queue_t main = dispatch_get_main_queue();
dispatch_async(queue,^{
CGFLoat num = [self doSomeMassiveComputation];
dispatch_async(main,^{
[self updateUIWithNumber:num];
});
});
@yene
yene / gist:763462
Created January 3, 2011 13:25
Fix for NSURLProtocol
//
// main.m
//
#import "NSURLProtocol+Fix.h"
int main(int argc, char *argv[])
{
[NSURLProtocol fix];
return NSApplicationMain(argc, (const char **) argv);
@yene
yene / index.html
Last active July 16, 2018 13:53
HTML5 Template
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>My shiny site</title>
<!-- used some CSS from https://github.com/twbs/bootstrap/blob/v4-dev/dist/css/bootstrap-reboot.css -->
<style>
html {
@yene
yene / gist:944523
Created April 27, 2011 15:50
loading nib and obtaining ref to the nswindow, all in code
NSMutableArray* topLevelObjs = [NSMutableArray array];
NSDictionary* nameTable = [NSDictionary dictionaryWithObjectsAndKeys:self, NSNibOwner, topLevelObjs, NSNibTopLevelObjects, nil];
if (![[NSBundle mainBundle] loadNibFile:@"bla" externalNameTable:nameTable withZone:nil]) {
NSLog(@"trouble loading bla.xib");
return;
}
for (id object in topLevelObjs) {
if ([object isKindOfClass:[NSWindow class]]) {
[object makeKeyAndOrderFront:nil];
break;
@yene
yene / gist:964741
Created May 10, 2011 15:53
pre-commit hook which uses clang static analyter before commit
#!/bin/sh
RESULT=$(xcodebuild -configuration Debug RUN_CLANG_STATIC_ANALYZER=YES)
if `echo ${RESULT} | grep "generated." 1>/dev/null 2>&1`
then
echo "commit failed: anaylzer error found"
exit 1
fi
@yene
yene / index.php
Created June 3, 2011 14:39
simple language detection in php
<?php
define(DEBUG, 0);
$supported_languages = array("en", "de");
$default_language = "en";
$language = $default_language;
if (isset($_POST['lang']) && in_array($_POST['lang'], $supported_languages)) { // Detecting if param was set
$language = $_POST['lang'];
setcookie("language", $language, time()+ (3600 * 24 * 30)); // cache 30 days
if (DEBUG) echo "found parameter lang " .$language;
@yene
yene / gist:7840570
Last active December 30, 2015 14:09
Custom marked renderer for gist code quotes
var r = new marked.Renderer()
var oldCode = r.code;
r.code = function(code, lang) {
if (lang === "gist") {
return '<code gist="https://gist.github.com/' + code + '.json"></code>';
} else {
return oldCode(code, lang);
}
}
@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