Skip to content

Instantly share code, notes, and snippets.

@phawk
phawk / payhere_embed_demo.html
Created February 17, 2019 17:41
PayHere embed
<button data-payhere-embed="https://payhere.co/altlabs/membership/pro-plan">Subscribe now</button>
<script src="https://payhere.co/embed/embed.js"></script>
@phawk
phawk / non-single-use.html.erb
Created December 4, 2017 22:06
Single use classes HTML bloat
<%= page_title("Account") %>
<%= render 'my_account/shared/header', current_section: "rewards" %>
<div class="container">
<div class="tab-content">
<div class="grid">
<div class="col-2-3">
<h3 class="heading">Bonus Points <span>2/8 bonus points earned</span></h3>
<p>Get even greater value from your rewards points by redeeming them against these special offers below. These offers are a one time only use and only unlock as and when you reach the Rewards Level required to do so.</p>
server {
listen 80;
server_name ~^(?P<sitename>.+)\.dev\.com$
access_log /var/www/vhosts/$sitename/logs/nginx.access.log;
error_log /var/www/vhosts/$sitename/logs/nginx.error.log;
root /var/www/vhosts/$sitename/public;
autoindex on;
index index.php;
include global/static-asset-caching.conf;
@phawk
phawk / git-notes.sh
Created November 25, 2013 09:42
Shows all Pull requests in the current branch not yet in origin/master. Useful for quick release notes
git log HEAD...origin/master --pretty=oneline | grep pull
@phawk
phawk / dropbox-cursor-issues.rb
Last active December 28, 2015 12:05
Dropbox cursor issues
# The examples are in Ruby using RestClient (an http library)
# Already have a cursor for this user retreived the last time I called /2/files/list_folder/continue
# 1AAFFUB2KR3h0S0317__4aWVmvEQwDmIR2fdxsGL4cZGqiZjavby0HkZT70COXZm6XlswiDTQXSM7ir1qZX9uGoKGI9FbI7dSiquLv9-shzV8qOb126UToXHiKfe_oDFRzCg
resp = RestClient.post(
"https://api.dropboxapi.com/2/files/list_folder/continue",
{
cursor: "1AAFFUB2KR3h0S0317__4aWVmvEQwDmIR2fdxsGL4cZGqiZjavby0HkZT70COXZm6XlswiDTQXSM7ir1qZX9uGoKGI9FbI7dSiquLv9-shzV8qOb126UToXHiKfe_oDFRzCg"
{
"entries": [{
".tag": "folder",
"name": "flashed",
"path_lower": "/flashed",
"id": "id:aJSxKm7T6cAAAAAAAAAAAg"
}, {
".tag": "file",
"name": "tumblr_nrjpzx4aAl1t7ikjqo1_1280.jpg",
"path_lower": "/flashed/tumblr_nrjpzx4aal1t7ikjqo1_1280.jpg",
def my_sample_method
# inputs
people = []
# work
people = Person.all
raise CustomError, "No people found." unless people.size > 0
# outputs
return people.to_json
require_relative "../../../acceptance_helper.rb"
# require File.expand_path("../../../../acceptance_helper", __FILE__)
describe "api/v1/colours" do
before do
@data = {
url: "http://illustrationage.files.wordpress.com/2013/08/breaking-bad-walter-white-darth-heisenberg-pj-mcquade-9.jpg",
filename: "breaking-bad-walter-white-darth-heisenberg-pj-mcquade-9.jpg"
}
end
@phawk
phawk / remove-old-git-branches.sh
Created September 25, 2013 14:40
Removes git branches already merged into master
# Remove git branches from stuff
function rmb {
current_branch=$(git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/')
if [ "$current_branch" != "master" ]; then
echo "WARNING: You are on branch $current_branch, NOT master."
fi
echo "Fetching merged branches..."
git remote prune origin
remote_branches=$(git branch -r --merged | grep -v '/master$' | grep -v "/$current_branch$")
local_branches=$(git branch --merged | grep -v 'master$' | grep -v "$current_branch$")
@phawk
phawk / cors.rb
Created April 24, 2013 09:14
Quick and dirty cors implementation for a rails controller.
before_filter :cors_preflight_check
after_filter :cors_set_access_control_headers
# For all responses in this controller, return the CORS access control headers.
def cors_set_access_control_headers
headers['Access-Control-Allow-Origin'] = '*'
headers['Access-Control-Allow-Methods'] = 'POST, GET, OPTIONS'
headers['Access-Control-Max-Age'] = "1728000"
end