Skip to content

Instantly share code, notes, and snippets.

View nubbel's full-sized avatar

Dominique d'Argent nubbel

View GitHub Profile
1::Mar 15 21:11:37.479 [72516] <172.19.173.195> {LogElapsedTime (common.php:74)} Time since script start: 215us [https://FQDN/devicemanagement/mdm/dep_mdm_enroll]
1::Mar 15 21:11:37.479 [72516] <172.19.173.195> {require_once (dep_mdm_enroll.php:11)} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv - POST dep_mdm_enroll
0::Mar 15 21:11:37.482 [72516] <172.19.173.195> {_exception_error_handler (dep_mdm_enroll.php:39)} Caught error 'Undefined index: HTTP_X_FORWARDED_SERVER' of severity 8 at /Applications/Server.app/Contents/ServerRoot/usr/share/devicemgr/backend/php/dep_mdm_enroll.php:39
0::Mar 15 21:11:37.482 [72516] <172.19.173.195> CONTEXT: Array
0::Mar 15 21:11:37.482 [72516] <172.19.173.195> (
0::Mar 15 21:11:37.482 [72516] <172.19.173.195> [args] => Array
0::Mar 15 21:11:37.482 [72516] <172.19.173.195> (
0::Mar 15 21:11:37.482 [72516] <172.19.173.195> [IMEI] => IMEI
0::Mar 15 21:11:37.482 [72516] <172.19.173.195> [LANGUAGE] => de
0::Mar 15 21:11:37.482 [72516] <172.19.173.195>
@perplexes
perplexes / Rakefile.rb
Created June 4, 2012 16:00
How to have multithreaded workers in delayed_job 3.0.3 and Ruby 1.9.3 and Rails 3.2.2
task :workers => :environment do
module Delayed
class Worker
def name_with_thread_id(*a, &b)
name_without_thread_id(*a, &b) + " thread:#{Thread.current.object_id}"
end
alias_method_chain :name, :thread_id
end
end
Rails.logger.info "Running threaded worker env."
@cfstras
cfstras / tcp-chat.js
Last active December 18, 2015 01:39
Chatserver
// Bib's
var net = require('net');
// Fettes Array
var clients = [];
// create teh server!
var srv = net.createServer();
// connection handler, das Argument ist ein Socket mit der neuen Verbindung
@fchaillou
fchaillou / AlamofireExtensions.swift
Created March 1, 2016 00:00
Alamofire Result to Antitypical Result conversion
import Alamofire
import Foundation
import enum Result.Result
extension Alamofire.Result {
func toStandard() -> Result<Value, Error> {
switch(self) {
case Alamofire.Result.Success(let value) : return Result.Success(value)
case Alamofire.Result.Failure(let error) : return Result.Failure(error)
}
@tomconroy
tomconroy / Event.swift
Last active December 22, 2016 20:57
A simple Event Emitter for swift (use EmitterKit for something more robust)
class Event <T:Any> {
var handlers = Array<(T) -> Void>()
func listen(handler: (T) -> Void) {
handlers.append(handler)
}
func emit(object: T) {
for handler in handlers {
handler(object)
package correlate
import (
"dft"
"fmt"
"math/cmplx"
)
// Cross-correlation is a measure of similarity of two waveforms as a function
// of a time-lag applied to one of them. Aka the sliding dot product. This is
// from and to are objects that live somewhere else (for examples sake)
uiGmapGoogleMapApi.then(function(maps){
var directionsService = new maps.DirectionsService();
var request = {
origin: new maps.LatLng(
from.lat(),
from.lng()
),
@seanlilmateus
seanlilmateus / channel.swift
Last active November 22, 2017 14:02
swift Go like channels
import Foundation
// Playground - noun: a place where people can play
class Channel<T> {
var stream: Array<T>
let queue: dispatch_queue_t
let semaphore: dispatch_semaphore_t
init() {
self.stream = []
@steipete
steipete / NSFormattingContextPlayground.m
Last active December 21, 2017 17:52
NSFormattingContextDynamic got my attention, so I've digged into how this actually works. (tl;dr: _NSStringProxyForContext!)
// NSFormattingContext is new in iOS 8. For NSFormattingContextDynamic it promises is following:
// The capitalization context is determined dynamically from the set {NSFormattingContextStandalone, NSFormattingContextBeginningOfSentence, NSFormattingContextMiddleOfSentence}. For example, if a date is placed at the beginning of a sentence, NSFormattingContextBeginningOfSentence is used to format the string automatically. When this context is used, the formatter will return a string proxy that works like a normal string in most cases. After returning from the formatter, the string in the string proxy is formatted by using NSFormattingContextUnknown. When the string proxy is used in stringWithFormat:, we can determine where the %@ is and then set the context accordingly. With the new context, the string in the string proxy will be formatted again and be put into the final string returned from stringWithFormat:.
// Here's a simple example:
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
dateFor
@carlfish
carlfish / gist:6b9761670a131f821ad5
Last active February 3, 2018 23:21
Why understanding monads is important.

Either and Promises/Futures are useful and I’ll use them next time they’re appropriate. But outside Haskell does their monad-ness matter?

(All code below is written in some made-up Java-like syntax, and inevitably contains bugs/typos. I'm also saying "point/flatMap" instead of "return/bind" because that's my audience. Any correspondance with anything that either be programatically or mathematically useful is coincidental)

What is a monad? A refresher.

A monad is something that implements "point" and "flatMap" correctly.