Skip to content

Instantly share code, notes, and snippets.

Avatar

José Albornoz eljojo

View GitHub Profile
@eljojo
eljojo / Item URI2.js
Created December 21, 2022 16:54
zotero uri
View Item URI2.js
{
"translatorID":"90ed0f17-6ead-42fe-afb9-d34adb230099",
"translatorType":2,
"label":"Item URI para cucho",
"creator":"jojo",
"target":"html",
"minVersion":"2.0",
"maxVersion":"",
"priority":200,
"inRepository":false,
@eljojo
eljojo / hardware-raspberry-pi.nix
Created January 9, 2022 01:12
nixos raspberry pi
View hardware-raspberry-pi.nix
{ config, lib, pkgs, modulesPath, ... }:
{
imports =
[
"${fetchTarball "https://github.com/NixOS/nixos-hardware/archive/2a7063461c3751d83869a2a0a8ebc59e34bec5b2.tar.gz" }/raspberry-pi/4"
];
boot.kernelPackages = pkgs.linuxPackages_rpi4;
boot.kernel.sysctl."vm.swappiness" = 0;
View gist:885b007b510e211d53451b15d4f60edd
[Unit]
After=docker.service docker.socket
After=ifup@eth0.service
Wants=ifup@eth0.service
[Service]
ExecStart=/usr/bin/docker run \
--rm \
--name=traefik \
View debug_turbolinks.patch
@eljojo
eljojo / 0_reuse_code.js
Created July 5, 2017 13:17
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@eljojo
eljojo / string_each_match.rb
Created September 1, 2013 17:12
String#each_match, kind of like String#scan but returning MatchData instead of the simple match. It takes a block as well!
View string_each_match.rb
class String
def each_match(regex)
result = []
position = 0
while match_data = regex.match(self, position) do
result << if block_given? then yield(match_data) else match_data end
position = match_data.end(match_data.size - 1)
end
@eljojo
eljojo / frown.coffee
Created August 21, 2013 10:48
show frown face
View frown.coffee
show_frown_gif = ->
@result.html $('<img>').attr('src', 'http://mrwgifs.com/wp-content/uploads/2013/07/Zooey-Deschanels-Cute-Sad-Frown.gif')
@eljojo
eljojo / amazon_item.rb
Last active December 19, 2015 15:29
Simple Amazon Product Advertisement api client, using Vacuum and Nokogiri. https://github.com/hakanensari/vacuum
View amazon_item.rb
class AmazonItem
attr_accessor :asin, :url, :manufacturer, :category, :title, \
:ean, :item_number, :model, :lowest_price, :image_url, \
:list_price, :offer_price
def initialize(attributes = {})
update_attributes(attributes)
end
def update_attributes(new_attributes)
@eljojo
eljojo / http_client.rb
Created July 5, 2013 08:40
simple ruby http client that allows you to use :TLSv1, for old servers that fail with OpenSSL 1.0.1e. https://raw.github.com/eljojo/polar_express/master/lib/polar_express/http_client.rb
View http_client.rb
class HTTPClient
attr_accessor :old_tls, :use_ssl
def initialize(opts = {})
config = {
old_tls: true,
use_ssl: nil,
}.merge(opts)
@old_tls = config[:old_tls]
@eljojo
eljojo / humanize_seconds.rb
Created June 24, 2013 14:15
How to generate a human readable time range using ruby on rails
View humanize_seconds.rb
# modification of http://stackoverflow.com/questions/4136248/how-to-generate-a-human-readable-time-range-using-ruby-on-rails
def humanize_seconds secs, precision = 2
return unless secs
units = [[60, :second], [60, :minute], [24, :hour], [1000, :day]]
diffs = units.map do |count, name|
next if units.find_index([count, name]) > precision
if secs > 0
secs, n = secs.divmod(count)
pluralize(n.to_i, name.to_s) if n > 0
end