Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View fastjames's full-sized avatar

Jim Kane fastjames

View GitHub Profile
@fastjames
fastjames / convert_to_verified_routes.ex
Created June 16, 2023 21:44 — forked from andreaseriksson/convert_to_verified_routes.ex
This is a mix task for converting old Phoenix routes to new verified routes
defmodule Mix.Tasks.ConvertToVerifiedRoutes do
@shortdoc "Fix routes"
use Mix.Task
@regex ~r/(Routes\.)(.*)_(path|url)\(.*?\)/
@web_module MyAppWeb
def run(_) do
Path.wildcard("lib/**/*.*ex")
### Keybase proof
I hereby claim:
* I am fastjames on github.
* I am fastjames (https://keybase.io/fastjames) on keybase.
* I have a public key ASDL6YrtoFS2096KuJbS1spHSAt10hIUDVR8vWgazzHQMgo
To claim this, I am signing this object:
@fastjames
fastjames / reclaimWindows10.ps1
Last active January 10, 2017 12:54 — forked from alirobe/reclaimWindows10.ps1
"Reclaim Windows 10" turns off a bunch of unnecessary Windows 10 telemetery, removes bloatware, and privacy invasions. Review and tweak before running. Scripts for reversing are included and commented. Fork via https://github.com/Disassembler0 (different defaults)
##########
# Win10 Initial Setup Script
# Author: Disassembler <disassembler@dasm.cz>
# Version: 1.7, 2016-08-15
# dasm's script: https://github.com/Disassembler0/Win10-Initial-Setup-Script/
# THIS IS A PERSONALIZED VERSION
# This script leaves more MS defaults on, including MS security features.
# Tweaked based on personal preferences for @alirobe 2016-11-16 - v1.7.1
@fastjames
fastjames / math_mean.exs
Created August 7, 2015 14:13
Probably bad mean in elixir
defmodule FastMath do
def mean([]), do: 0
def mean([a]), do: a
def mean(list) do
_mean(list, 0, 0)
end
# terminal condition
defp _mean([], total, count) do

Using Unicorn with Upstart

This configuration works with Upstart on Ubuntu 12.04 LTS

The reason why it needs to be done this way (i.e. with the pre-start and post-stop stanzas), is because Upstart is unable to track whever Unicorn master process re-execs itself on hot deploys. One can use it without hot-deploys and run Unicorn in foreground also, it then only needs one exec stanza.

This presumes you are not using RVM, so no voodoo dances.

@fastjames
fastjames / gist:2725983
Created May 18, 2012 15:52 — forked from dignoe/gist:2485272
Patch to get content_for working with action caching and fragment caching in Rails 3.1
module ActionController
class Metal
attr_internal :cached_content_for
end
module Caching
module Actions
def _save_fragment(name, options)
return unless caching_allowed?