Skip to content

Instantly share code, notes, and snippets.

View hapiben's full-sized avatar

Ben hapiben

View GitHub Profile
@ceving
ceving / Web Component for Copyright Years.md
Last active April 29, 2024 07:06
Web Component for Copyright Years
@TehBrian
TehBrian / final-cut-pro-trial-reset.sh
Created June 21, 2022 19:33
Final Cut Pro Trial Reset
mv -v ~/Library/Application\ Support/.ffuserdata ~/.Trash
@dannote
dannote / final-cut-pro-trial-reset.swift
Last active April 17, 2024 10:39
Final Cut Pro X trial reset
#!/usr/bin/swift
import Foundation
let path = URL(fileURLWithPath: NSString(string: "~/Library/Application Support/.ffuserdata").expandingTildeInPath)
let data = try! NSData(contentsOf: path) as Data
let dictionary = try! NSKeyedUnarchiver.unarchiveTopLevelObjectWithData(data) as! NSDictionary
let mutableDictionary = dictionary.mutableCopy() as! NSMutableDictionary
for (key, value) in mutableDictionary {
@RoyalIcing
RoyalIcing / Dockerfile
Last active April 2, 2020 17:06
Rails 5.1 Dockerfile
FROM ruby:2.4-alpine
ENV PATH /root/.yarn/bin:$PATH
RUN apk update && apk upgrade && \
apk add --no-cache bash git openssh build-base nodejs tzdata
RUN apk update \
&& apk add curl bash binutils tar gnupg \
&& rm -rf /var/cache/apk/* \
@hapiben
hapiben / spca-wellington-flickr-parser.rb
Last active November 4, 2016 02:23
Example SJ Manager parser for SPCA Wellington Flickr
# Content Parner: Wellington SPCA
# Data Source: SPCA Wellington Flickr
class SPCAWellingtonFlickr < SupplejackCommon::Xml::Base
base_url 'https://api.flickr.com/services/rest/?method=flickr.photosets.getPhotos&api_key=66881cbc6259eae63ceb6d6453159892&user_id=73889498@N04&photoset_id=72157628780736141&privacy_filter=1&extras=description,%20license,%20date_taken,%20owner_name,%20geo,%20tags,%20media,%20machine_tags,%20url_m,%20url_z,%20url_o&format=rest'
paginate page_parameter: 'page', type: 'page', per_page_parameter: 'per_page', per_page: 100, page: 1, total_selector: '//*[1]/@total'
record_selector '//photo'
record_format :xml
throttle host: 'api.flickr.com', delay: 1
@cecilemuller
cecilemuller / letsencrypt_2020.md
Last active April 15, 2024 02:19
How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SSL rating)

How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SLL rating)


Virtual hosts

Let's say you want to host domains first.com and second.com.

Create folders for their files:

@dhh
dhh / test_induced_design_damage.rb
Last active June 22, 2023 06:18
This is an extraction from Jim Weirich's "Decoupling from Rails" talk, which explained how to apply the hexagonal design pattern to make every layer of your application easily unit testable (without touching the database etc). It only seeks to extract a single method, the EmployeesController#create method, to illustrate the design damage that's …
# Original Rails controller and action
class EmployeesController < ApplicationController
def create
@employee = Employee.new(employee_params)
if @employee.save
redirect_to @employee, notice: "Employee #{@employee.name} created"
else
render :new
end
@brianburridge
brianburridge / gist:11298396
Last active October 8, 2023 12:49
How to load MySQL time zone tables from Mac OS time zone files

The easiest way to load the Mysql Time Zone tables from your Mac OS time zone fields is via this command:

mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root mysql

However, on many systems like mine that will fail because some of the time zone information is incompatible with the database schema for the time zone tables.

Therefore, you'll want to load the time zone information into a text file and edit it to only include the time zones you need. (Or, attempt to find the data breaking the import.)

mysql_tzinfo_to_sql /usr/share/zoneinfo > zone_import.sql
@ungoldman
ungoldman / dokku_setup.md
Last active November 28, 2023 12:35
Deploy your own PaaS: Setting up Dokku with DigitalOcean and Namecheap

Deploy your own PaaS!

Setting up Dokku with DigitalOcean and Namecheap

..or how I made my own heroku in a few hours for $3.98.


This write-up is several years out of date! You probably shouldn't use it.

@bogdanconstantinescu
bogdanconstantinescu / application.rb
Created May 9, 2012 15:26 — forked from t2/application.rb
Formatting Rails form elements for Twitter Bootstrap error validation
ActionView::Base.field_error_proc = Proc.new do |html_tag, instance|
html = %(<div class="field_with_errors">#{html_tag}</div>).html_safe
# add nokogiri gem to Gemfile
form_fields = [
'textarea',
'input',
'select'
]