Skip to content

Instantly share code, notes, and snippets.

View cypres's full-sized avatar

Hans Arnholm cypres

View GitHub Profile
@cypres
cypres / gpoint.php
Created February 23, 2011 14:20
PHP class to convert Latitude & Longitude coordinates into UTM & Lambert Conic Conformal Northing/Easting coordinates.
<?php
/**
* PHP class to convert Latitude & Longitude coordinates into UTM & Lambert Conic Conformal Northing/Easting coordinates.
*
* This class encapsulates the methods for representing a geographic point on the earth in three different coordinate systema. Lat/Long, UTM and Lambert Conic Conformal.
*
* Code for datum and UTM conversion was converted from C++ code written by Chuck Gantz (chuck.gantz@globalstar.com) from http://www.gpsy.com/gpsinfo/geotoutm/
* This code was converted into PHP by Brenor Brophy (brenor@sbcglobal.net) and later refactored for PHP 5.3 by Hans Duedal (hd@onlinecity.dk).
*
@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 / daemon.cc
Created April 2, 2014 08:49
C++ example daemon with fork and relaunch should child die. Required C++11, gflags and glog.
//
// Copyright (C) 2011-2012 Yaroslav Stavnichiy <yarosla@gmail.com>
// Copyright (C) 2014 OnlineCity Aps <hd@oc.dk>
//
// Inspired by: https://bitbucket.org/yarosla/nxweb/src/tip/src/lib/daemon.c
//
// Licensed under The MIT License:
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
@cypres
cypres / benchmark.js
Created July 19, 2011 13:40
node js redis benchmark
var redis = require("redis"), client = redis.createClient(6379,'127.0.0.1');
// Benchmark params
var data = 'O:10:"SmsRequest":5:{s:2:"id";i:550845359;s:6:"sender";s:10:"OnlineCity";s:7:"message";s:140:"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus blandit faucibus magna, vitae accumsan orci iaculis sed. Morbi cras amet.";s:10:"recipients";a:1:{i:0;i:4526159917;}s:10:"dataCoding";i:0;}';
var n = 20000;
var start;
var lastOp;
client.on("error", function (err) {
console.log("Error " + err);
@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))
@cypres
cypres / oauth.cc
Last active January 23, 2021 16:39
Two-legged OAuth 1.0a in C++11
//
// Two-legged OAuth 1.0a proof of concept
// Feel free to use, copy or modify to your own needs.
//
// Requires glog, gflags and crypto++ (cryptopp.com)
// Compile with:
// clang++ -std=c++11 -lcryptopp -lglog -lgflags oauth.cc -o oauth_test
// Run with:
// ./oauth_test -alsologtostderr
//
@cypres
cypres / baraction.sh
Created January 3, 2021 23:29
baraction.sh script for spectrwm status bar
#!/bin/bash
# baraction.sh script for spectrwm status bar
print_backlight() {
if [ -e /sys/class/backlight/intel_backlight/brightness ]; then
BL=$(oled-backlight current)
echo -n " BL:$BL%"
else
echo -n " BL:Unknown"
fi
@cypres
cypres / zfs_report.sh
Created December 19, 2011 21:35
ZFS scripts
#!/bin/sh
echo "ZFS listing:"
/sbin/zfs list
echo
echo "ZFS compression ratio:"
/sbin/zfs get compressratio | /usr/bin/grep -v @
echo
--- a/tutorial/cpp/CppClient.cpp
+++ b/tutorial/cpp/CppClient.cpp
@@ -38,9 +38,9 @@
using namespace boost;
int main(int argc, char** argv) {
- shared_ptr<TTransport> socket(new TSocket("localhost", 9090));
- shared_ptr<TTransport> transport(new TBufferedTransport(socket));
- shared_ptr<TProtocol> protocol(new TBinaryProtocol(transport));
+ boost::shared_ptr<TTransport> socket(new TSocket("localhost", 9090));
@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>