Skip to content

Instantly share code, notes, and snippets.

View Fryie's full-sized avatar

Pierpaolo Frasa Fryie

  • Berlin, Germany
View GitHub Profile
@Fryie
Fryie / search.js
Created June 13, 2014 12:05
CSS Search
// Modified from http://redotheweb.com/2013/05/15/client-side-full-text-search-in-css.html
// you'll need to add type='text/css' to the style tag in the HTML for this to work in IE<9
(function() {
var addslashes = function(str) {
return (str + '')
.replace(/[\\"']/g, '\\$&')
.replace(/\u0000/g, '\\0');
};
@Fryie
Fryie / PKGBUILD
Created January 19, 2015 00:34
Exercism CLI v1.9.2 PKGBUILD
# Maintainer: linduxed <[email protected]>
pkgname=exercism-cli
pkgver=v1.9.2
pkgrel=1
pkgdesc="Command line client for exercism.io"
arch=("i686" "x86_64")
url="https://github.com/exercism/cli"
license=("MIT")
@Fryie
Fryie / application.controller.js
Created August 28, 2015 14:56 — forked from KTKate/application.controller.js
Why Won't my component click
import Ember from 'ember';
export default Ember.Controller.extend({
didIClick: 'No Clicks!',
actions: {
otherAction(){
alert('controller action');
return true;
}
}
@Fryie
Fryie / application.controller.js
Created September 16, 2015 10:15
disabledWhen
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle',
alertDisabled: Ember.observer('checked', function() {
var disabled = Ember.$('#link').hasClass('disabled');
console.log(`link disabled: ${disabled}`);
})
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle'
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle'
});
@Fryie
Fryie / email_worker_proxy.rb
Created January 7, 2016 17:07
Sidekiq Proxy Workers
class EmailWorkerProxy
include WorkerProxy
sidekiq_options queue: 'email', retry: false
end
@Fryie
Fryie / kclass.rb
Created February 1, 2016 13:27
easy keyword classes
module KClass
def self.[](*keywords)
klass = Class.new
klass.send(:define_method, :initialize) do |hash|
keywords.each do |kw|
instance_variable_set("@#{kw}", hash[kw])
end
end
keywords.each do |kw|
@Fryie
Fryie / pi_monte_carlo.jl
Last active May 24, 2020 01:49
Estimating pi by the monte carlo method
using Distributions
function estimate_pi(n) # the higher n is, the more accurate the estimate will be
hits = 0
for i=1:n
x = rand(Uniform(-1,1))
y = rand(Uniform(-1,1))
if x*x + y*y <= 1
hits += 1
end
@Fryie
Fryie / cancan_bug.rb
Last active December 18, 2020 00:50 — forked from coorasse/main.rb
CanCanCan Issue
begin
require 'bundler/inline'
rescue LoadError => e
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
raise e
end
gemfile(true) do
source 'https://rubygems.org'
gem 'rails' # use correct rails version