Skip to content

Instantly share code, notes, and snippets.

Felix Holmgren felixyz

View GitHub Profile
@felixyz
felixyz / gist:329cdecebbd73d001005cdf530877cb5
Created May 20, 2018
pakcs-2.0.1 install failure log (OS X)
View gist:329cdecebbd73d001005cdf530877cb5
/Applications/Xcode.app/Contents/Developer/usr/bin/make config 2>&1 | tee -a make.log
cd scripts && /Applications/Xcode.app/Contents/Developer/usr/bin/make all
/Applications/Xcode.app/Contents/Developer/usr/bin/make /Users/felix/code/pakcs-2.0.1/bin/pakcs /Users/felix/code/pakcs-2.0.1/bin/pakcs-makecgi /Users/felix/code/pakcs-2.0.1/bin/cleancurry /Users/felix/code/pakcs-2.0.1/bin/pakcs-fcypp
mkdir -p /Users/felix/code/pakcs-2.0.1/bin
cat pakcs.sh | sed "s|^PAKCSBUILDDIR=.*$|PAKCSBUILDDIR=/Users/felix/code/pakcs-2.0.1|" | \
sed "s|^PAKCSINSTALLDIR=.*$|PAKCSINSTALLDIR=|" > /Users/felix/code/pakcs-2.0.1/bin/pakcs
chmod 755 /Users/felix/code/pakcs-2.0.1/bin/pakcs
mkdir -p /Users/felix/code/pakcs-2.0.1/bin
cat pakcs-makecgi.sh | sed "s|^PAKCSBUILDDIR=.*$|PAKCSBUILDDIR=/Users/felix/code/pakcs-2.0.1|" | \
sed "s|^PAKCSINSTALLDIR=.*$|PAKCSINSTALLDIR=|" > /Users/felix/code/pakcs-2.0.1/bin/pakcs-makecgi
@felixyz
felixyz / impuzzable.pi
Created Nov 26, 2017
Impuzzable in Picat
View impuzzable.pi
% Impuzzable
% https://nrich.maths.org/1388
import cp.
import util.
main =>
puzzle(Pieces),
time2(Arrangements = find_all_arrangements(Pieces)),
@felixyz
felixyz / converter.rb
Last active Oct 6, 2017
dry-validation form => json schema
View converter.rb
module DryJsonSchema
# Transforms a dry-validation form to json-schema-compatible objects (hash or array)
# Usage:
# DryJsonSchema::Converter.(my_form)
# => { :type => :object,
# :properties => { :abc => { :type => :integer },
# :xyz => { :type => :integer }
# },
# :required => [:abc]}
class Converter
View mini-case.eve
```
commit
[#world tick: 0]
[#time #system/timer resolution: 1000]
[#thing value: 1 delta: 1]
```
Update
~~~
search
@felixyz
felixyz / gist:872d0567e0d58d6e6aac
Created Mar 16, 2015
dokku nginx config http + https
View gist:872d0567e0d58d6e6aac
server {
listen [::]:80;
listen 80;
server_name $NOSSL_SERVER_NAME;
location / {
proxy_pass http://$APP;
proxy_http_version 1.1;
proxy_set_header Upgrade \$http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host \$http_host;
@felixyz
felixyz / runflora log
Last active Aug 29, 2015
Flora-2 failures on OSX
View runflora log
$ ./flora2/runflora
% Specialising partially instantiated calls to flora_assert_directories/1
[Compiling Foreign Module /Users/felix/Documents/code/flora2/flora2bundle/flora2/cc/prolog2hilog (Prolog compiler options are ignored)]
[prolog2hilog compiled, cpu time used: 0.0010 seconds]
[Compiling C file /Users/felix/Documents/code/flora2/flora2bundle/flora2/cc/prolog2hilog.c using gcc]
/Users/felix/Documents/code/flora2/flora2bundle/flora2/cc/prolog2hilog.c:365:9: warning: comparison of 0 > unsigned expression is always false [-Wtautological-compare]
if (0 > length_diff) return FALSE;
~ ^ ~~~~~~~~~~~
1 warning generated.
gcc -dynamiclib -undefined dynamic_lookup -fPIC -o /Users/felix/Documents/code/flora2/flora2bundle/flora2/cc/prolog2hilog.dylib /Users/felix/Documents/code/flora2/flora2bundle/flora2/cc/prolog2hilog.c -Wall -fPIC -I/Users/felix/Documents/code/flora2/flora2bundle/XSB/emu -I/Users/felix/Documents/code/flora2/flora2bundle/XSB/config/i386-apple-darwin13.2.0 -O3 -fno-strict-aliasing -
@felixyz
felixyz / Intro to Common Table Expressions.md
Last active Nov 19, 2018
Introduction to transitive closure / Common Table Expressions / iterative queries in SQL
View Intro to Common Table Expressions.md

Teh Social Netswork!

CREATE TABLE users (
 id SERIAL PRIMARY KEY,
 name VARCHAR(10) NOT NULL
);


INSERT into users VALUES
@felixyz
felixyz / sidekiq_unique_jobs_bug_spec.rb
Created Feb 3, 2014
RSpec script attempting (and failing) to reproduce sidekiq-unique-jobs issue #27. https://github.com/mhenrixon/sidekiq-unique-jobs/issues/27
View sidekiq_unique_jobs_bug_spec.rb
require 'spec_helper'
require 'sidekiq'
require 'sidekiq/middleware/chain'
require 'sidekiq/fetch'
require 'sidekiq/processor'
require 'redis/namespace'
redis_url = 'redis://localhost/15'
client = Redis.connect(:url => redis_url)
@felixyz
felixyz / item_insert_benchmark.rb
Created Sep 16, 2013
Compares speed of two different methods of inserting items in an array.
View item_insert_benchmark.rb
require 'benchmark'
def insert_then_sort(results, missing_items)
missing_items.each do |id|
results << {id: id, val: nil}
end
results.sort_by!{|item| item[:id] }
results
end
@felixyz
felixyz / gist:5788375
Created Jun 15, 2013
MRI pipe limit (on OS X). This script fails on my Mac after creating 125 x 2 pipe endpoints, raising "Too many open files (Errno::EMFILE)" This is the cause of the problem illustrated here: https://gist.github.com/Felixyz/5788285
View gist:5788375
wakeups = []
wakers = []
puts "Creating pipes..."
200.times do |n|
puts "[#{n}]"
wakeup, waker = IO.pipe
wakeups << wakeup
wakers << waker
You can’t perform that action at this time.