Skip to content

Instantly share code, notes, and snippets.

View felixyz's full-sized avatar

Felix Holmgren felixyz

View GitHub Profile
@felixyz
felixyz / gist:329cdecebbd73d001005cdf530877cb5
Created May 20, 2018 21:49
pakcs-2.0.1 install failure log (OS X)
/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 November 26, 2017 21:24
Impuzzable in Picat
% 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 May 23, 2020 18:40
dry-validation form => json schema
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
```
commit
[#world tick: 0]
[#time #system/timer resolution: 1000]
[#thing value: 1 delta: 1]
```
Update
~~~
search
@felixyz
felixyz / gist:872d0567e0d58d6e6aac
Created March 16, 2015 16:06
dokku nginx config http + https
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 August 29, 2015 14:11
Flora-2 failures on OSX
$ ./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 December 22, 2023 12:23
Introduction to transitive closure / Common Table Expressions / iterative queries in SQL

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 February 3, 2014 09:43
RSpec script attempting (and failing) to reproduce sidekiq-unique-jobs issue #27. https://github.com/mhenrixon/sidekiq-unique-jobs/issues/27
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 September 16, 2013 15:40
Compares speed of two different methods of inserting items in an array.
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 June 15, 2013 14:44
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
wakeups = []
wakers = []
puts "Creating pipes..."
200.times do |n|
puts "[#{n}]"
wakeup, waker = IO.pipe
wakeups << wakeup
wakers << waker