Skip to content

Instantly share code, notes, and snippets.

View drush's full-sized avatar

Darren Rush drush

View GitHub Profile
@Rynaro
Rynaro / component_mailer.rb
Created September 13, 2021 20:09
View component from Rails Mailers
# frozen_string_literal: true
class ComponentMailer < ApplicationMailer
def notify(me)
mail to: 'henrique@mail.com', subject: 'Component', body: ApplicationController.render(MyComponent.new(me: me))
end
end
@fishtek
fishtek / check_system.py
Created February 2, 2016 19:02
Helper script for consul health check.
#!/usr/bin/python
# ========================================================================================
# Check System
#
# Written by : Ryan Fisher rfisher@cyberpointllc.com
# Release : 1.0
# Creation date : 13 Jan 2016
# ========================================================================================
import psutil
@edolstra
edolstra / nix-ui.md
Last active February 2, 2024 23:31
Nix UI

General notes

  • nix-channel and ~/.nix-defexpr are gone. We'll use $NIX_PATH (or user environment specific overrides configured via nix set-path) to look up packages. Since $NIX_PATH supports URLs nowadays, this removes the need for channels: you can just set $NIX_PATH to e.g. https://nixos.org/channels/nixos-15.09/nixexprs.tar.xz and stay up to date automatically.

  • By default, packages are selected by attribute name, rather than the name attribute. Thus nix install hello is basically equivalent to nix-env -iA hello. The attribute name is recorded in the user environment manifest and used in upgrades. Thus (at least by default) hello won't be upgraded to helloVariant.

    @vcunat suggested making this an arbitrary Nix expression rather than an attrpath, e.g. firefox.override { enableFoo = true; }. However, such an expression would not have a key in the user environment, unlike an attrpath. Better to require an explicit flag for this.

TBD: How to deal with search path clashes.

@ricardo-rossi
ricardo-rossi / ElasticSearch.sh
Last active December 1, 2023 04:55
Installing ElasticSearch on Ubuntu 14.04
#!/bin/bash
### USAGE
###
### ./ElasticSearch.sh 1.7 will install Elasticsearch 1.7
### ./ElasticSearch.sh will fail because no version was specified (exit code 1)
###
### CLI options Contributed by @janpieper
### Check http://www.elasticsearch.org/download/ for latest version of ElasticSearch
@anasnakawa
anasnakawa / tiny-js-pubsub.js
Last active February 2, 2023 08:14
very tiny Pub/Sub implementation that utilizes native browser event methods. ( only browsers .. no IE8 )
/*! Js Pub/Sub
* http://anasnakawa.com/
* Copyright (c) Anas Nakawa
* inspired by Ben Alman's one <https://gist.github.com/cowboy/661855>
* MIT License
*/
(function( p ) {
var e = p.e = {};
@shesek
shesek / bitcoin-decoderawtransaction.coffee
Last active January 9, 2018 15:18
Decode Bitcoin raw transactions to bitcoinjs-lib's Transaction object with CoffeeScript
decode_raw_tx = do ->
{ Transaction, TransactionIn, TransactionOut } = Bitcoin
{ bytesToBase64 } = Crypto.util
# Parse an bytearray of length `size` as an integer
# Works for numbers up to 32-bit only
parse_int = (size) -> (bytes) ->
n = 0
n += (bytes.shift() & 0xff) << (8 * i) for i in [0...size]
@kares
kares / scheduled_job.rb
Created June 14, 2011 11:31
Recurring Job using Delayed::Job
#
# Recurring Job using Delayed::Job
#
# Setup Your job the "plain-old" DJ (perform) way, include this module
# and Your handler will re-schedule itself every time it succeeds.
#
# Sample :
#
# class MyJob
# include Delayed::ScheduledJob