Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<style>
.feld1 {
margin: 20px;
}
.feld2 {
@pk
pk / .sleep
Created January 10, 2019 14:37
Sleep script to stop all Docker containers
#!/bin/bash
exec &> ~/.sleep.log
# Author: pavel@fry-it.com
# Version: 0.0.1
echo ".sleep triggered at $(date)"
# This have to be here otherwise launchctl won't find Docker commands
DOCKER=/usr/local/bin/docker
- (IBAction)buttonTapped:(UIButton *)aSender {
self.validationErrors = nil;
// Translate Button -> Option
NSUInteger index = [self.buttonsView.subviews indexOfObject:aSender];
PQMarkSheetAnswer *selectedOption = (self.options)[index];
// When we have single choice we need to toggle options
if (!self.allowsMultipleSelection && [self.selectedOptions count] > 0) {
PQMarkSheetAnswer *alreadySelectedOption = [self.selectedOptions firstObject];
@pk
pk / document.html
Created April 2, 2015 13:55
Practique printout
<!doctype html>
<html lang="en_GB">
<head>
<meta charset="utf-8">
<title>Content</title>
<script type="text/javascript" src="./print.js"></script>
<style>
/* Page layout, header, footer */
body {
@pk
pk / gist:5552d00f36e624075302
Last active August 29, 2015 14:15
core/analytics.service.ts
angular
.module("core.analytics", [])
.service("Analytics", function($rootScope, $state){
this.handle = null;
this.setup = function(handle, trackerID){
if (!handle) {
console.log("Analytics: Unable to initialize plugin!");
return false;
@pk
pk / gist:ed17387907c12cdfece3
Created November 28, 2014 13:26
Angular AuthSession model
/**
* Authentication session handling token and user id
*/
angular.module('fn.services.authentication', [])
.service('srvAuthenticationSession', ['$window', function ($window) {
this.save = function() {
var data = {'userId':this.userId, 'token':this.token};
$window.localStorage['com.fansnation.authorisationSession'] = JSON.stringify(data);
}
@pk
pk / privnote.rb
Created May 27, 2014 14:34
Privnote naive implementation
require 'rubygems'
require 'bundler/setup'
require 'sinatra'
require 'securerandom'
NOTES = {}
get '/' do
response = '<html><body>'
response << %Q{<h1>Create secret note</h1>}
@pk
pk / Adjusted Helvetica Neue LT Std 95 Black.hhea.xml
Last active December 12, 2015 02:58
Fixing ascender/descender for Helvetica Neue LT Std 95 Black for iOS
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE hheaTable [
<!ELEMENT hheaTable EMPTY>
<!ATTLIST hheaTable versionMajor CDATA #IMPLIED
versionMinor CDATA #IMPLIED
ascender CDATA #IMPLIED
descender CDATA #IMPLIED
lineGap CDATA #IMPLIED
advanceWidthMax CDATA #IMPLIED
minLeftSideBearing CDATA #IMPLIED
@pk
pk / gist:4694383
Created February 1, 2013 21:46
Trusting certain hosts using NSURLConnection delegate to bypass SSL certificate validation.
- (BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace {
return [protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust];
}
- (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge {
if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust])
if ([[[GJEnvironment sharedEnvironment] trustedHosts] containsObject:challenge.protectionSpace.host])
[challenge.sender useCredential:[NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust] forAuthenticationChallenge:challenge];
[challenge.sender continueWithoutCredentialForAuthenticationChallenge:challenge];
@pk
pk / juicer_filter.rb
Created November 9, 2011 15:25
Nanoc Juicer filter for minifying CSS/JS
module PK
module Filter
class Juice < Nanoc3::Filter
identifier :juice
type :text
def run(content, params={})
input_filename = File.join('content', @item.path)
output_filename = File.absolute_path(File.join('tmp', "#{@item.path}"))