Skip to content

Instantly share code, notes, and snippets.

View cypres's full-sized avatar

Hans Arnholm cypres

View GitHub Profile
@cypres
cypres / Makefile.diff
Created April 16, 2015 17:51
Modified uWSGI Makefile to support multiple python version in same binary
diff -u /var/portshaker/freebsd/www/uwsgi/Makefile /var/portshaker/ocrepo/www/uwsgi/Makefile
--- /var/portshaker/freebsd/www/uwsgi/Makefile 2015-03-17 12:00:14.000000000 +0100
+++ /var/portshaker/ocrepo/www/uwsgi/Makefile 2015-04-16 19:47:51.000000000 +0200
@@ -12,20 +12,36 @@
LICENSE= GPLv2
LICENSE_FILE= ${WRKSRC}/LICENSE
-USES= python
+USES= python:2.7
USE_RC_SUBR= uwsgi
@cypres
cypres / UIImageExt.swift
Created March 16, 2015 14:06
UIImage from UIImagePickerController resize + fix orientation
import UIKit
extension UIImage {
// Based on http://stackoverflow.com/a/1262395/449607
// Optimized for JPEG output
func imageResized(longEdge : CGFloat) -> UIImage {
func radians (degrees : Double) -> CGFloat {
return CGFloat(degrees * M_PI/180)
}
@cypres
cypres / holiday.swift
Created January 16, 2015 23:58
Holiday calculation for iOS
// Playground - noun: a place where people can play
// This is free and unencumbered software released into the public domain.
// Anyone is free to copy, modify, publish, use, compile, sell, or
// distribute this software, either in source code form or as a compiled
// binary, for any purpose, commercial or non-commercial, and by any
// means.
// This playground calculates a set of opening hours keys, such as "every friday",
// "2. day in month friday", "easter sunday" etc, which can be used to figure out
@cypres
cypres / hello.php
Created October 31, 2014 12:39
nimta.com gateway hello world
<?php
(new SoapClient('https://soap.nimta.com?wsdl'))->sendSMSes(array(
'username' => 'USERNAME',
'password' => 'PASSWORD',
'gatewayClass' => 'A',
'messages' => array(
array(
'message' => 'Hello World!',
'charge' => 0,
'delayed' => false,
@cypres
cypres / ssl_params
Created October 17, 2014 14:43
SSL config to keep IE6 on XP Support and Forward Secrecy - yet mitigate POODLE and BEAST server side
# For nginx. Requires OpenSSL 1.0.1j
ssl_ciphers EECDH+ECDSA+AESGCM:EECDH+aRSA+AESGCM:EECDH+ECDSA+SHA384:EECDH+ECDSA+SHA256:EECDH+aRSA+SHA384:EECDH+aRSA+SHA256:EECDH+aRSA+RC4:EECDH:EDH+aRSA:RC4:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!SRP:!DSS:!CAMELLIA;
ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
@cypres
cypres / .ycm_extra_conf.py
Created October 6, 2014 13:38
YouCompleteMe extra conf
# This file is NOT licensed under the GPLv3, which is the license for the rest
# of YouCompleteMe.
#
# Here's the license text for this file:
#
# This is free and unencumbered software released into the public domain.
#
# Anyone is free to copy, modify, publish, use, compile, sell, or
# distribute this software, either in source code form or as a compiled
# binary, for any purpose, commercial or non-commercial, and by any
@cypres
cypres / keybase.md
Last active January 27, 2024 22:25
keybase.md

Keybase proof

I hereby claim:

  • I am cypres on github.
  • I am cyp (https://keybase.io/cyp) on keybase.
  • I have a public key ASCyjHoIq03nYt0VUveLHEBUrR6cQWFWhghU5OmD5npNLQo

To claim this, I am signing this object:

@cypres
cypres / UIImageTint.swift
Last active August 15, 2016 07:24
Tinting UIImage with Overlay (preserving grey scale info)
import UIKit
extension UIImage {
func imageGreyScale() -> UIImage {
let imageRect = CGRectMake(0, 0, self.size.width, self.size.height)
let greyContext = CGBitmapContextCreate(
nil, UInt(self.size.width*self.scale), UInt(self.size.height*self.scale),
8, 0,
CGColorSpaceCreateDeviceGray(),
@cypres
cypres / cidr.cc
Last active March 6, 2020 17:03
IPv4 in CIDR
#ifdef __FreeBSD__
#include <sys/socket.h>
#endif
#include <arpa/inet.h>
#include <netinet/in.h>
#include <cstdlib>
#include <cstring>
#include <cerrno>
#include <cassert>
#include <iostream>
@cypres
cypres / Easter.swift
Last active March 27, 2021 17:08
Easter calculation in Swift
// Easter calculation in swift after Anonymous Gregorian algorithm
// Also known as Meeus/Jones/Butcher algorithm
import Foundation
func easter(Y : Int) -> NSDate {
let a = Y % 19
let b = Int(floor(Double(Y) / 100))
let c = Y % 100
let d = Int(floor(Double(b) / 4))