Skip to content

Instantly share code, notes, and snippets.

;;; pbcopy.el --- Emacs Interface to pbcopy
;; Copyright (C) 2011 Daniel Nelson, based on xclip.el, by Leo Shidai Liu
;; This file is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3, or (at your option)
;; any later version.
;; This file is distributed in the hope that it will be useful,
@daniel-nelson
daniel-nelson / pre-push
Last active February 19, 2021 18:01
Confirm before pushing to production repositories. Place in .git/hooks/ and make executable
#!/bin/bash
if [[ "$1" =~ "production" ]]; then
read -a array
pushed_ref=${array[1]}
remote_ref=${array[3]}
echo
echo "# Commits:"
git log --oneline $remote_ref...$pushed_ref
module ModuleName
include OtherModules
delegate :some_method, to: :some_object
module ClassMethods
def class_method
end
end
#
# my solution to ListsAndRecursion-6 of Programming Elixir 1.6
#
defmodule MyList do
def flatten([]) do
[]
end
def flatten([head | tail]) when is_list(head) do
flatten(head) ++ flatten(tail)
require 'fileutils'
type_map = {
jpeg: 'Photos',
JPEG: 'Photos',
jpg: 'Photos',
JPG: 'Photos',
png: 'PNGs',
PNG: 'PNGs',
mov: 'Videos',
.fa-events-icons-failed {
&.icon {
&::before {
display: none;
}
&::after {
@extend .din-bold;
}
}
@daniel-nelson
daniel-nelson / gist:5884463
Created June 28, 2013 12:54
troubleshooting CloudFront
Request URL:http://d2l5dw7ow11yzt.cloudfront.net/339/254/0.5-0.5/assets/images/51b24a2054b709630c000024.jpg
Response Headers:
Age: 162
Cache-Control: public, must-revalidate, max-age=2592000
Connection: keep-alive
Content-Disposition: inline
Content-Length: 0
Content-Type: image/jpeg
Date: Fri, 28 Jun 2013 11:28:58 GMT
Server: nginx/1.2.3 + Phusion Passenger 3.0.11 (mod_rails/mod_rack)
Angular:
dashboard.module.es6 // Defines the DashboardApp
dashboard.controller.es6
order_queue.module.es6 // Defines the OrderQueueApp
order_queue.controller.es6
modal.directive.js // A general purpose directive for displaying modals. Modal html is loaded from templates
Angular Templates:
dashboard_order_info_modal.html // Renders order_info_details
order_queue_info_modal.html // Also renders order_info_details
@daniel-nelson
daniel-nelson / copy_assets_to_s3.rake
Created January 27, 2015 16:03
assets:copy_to_s3 rake task
namespace :assets do
desc 'copy precompiled assets to S3'
task :copy_to_s3 => :environment do
Rails.logger.info('Copying compiled assets to s3...')
s3 = AWS::S3.new
bucket = s3.buckets[APP_CONFIG[:rails_assets_bucket]]
base_dir = Rails.root.join('public', 'assets').to_s + '/'
regexp_extensions = []
['js', 'css', 'html', 'png', 'jpg', 'jpeg', 'gif', 'ttf', 'woff', 'svg', 'eot', 'otf'].each do |ext|
struct order *orders;
// ...
// *orders is assigned to point to a block of memory returned by ALLOC_N (from ruby.h)
// ...
// Data in *orders is fine here
struct winning_order winners[winners_length];
// Data in *orders is corrupt here (see below)
Subset of data pre and post local declaration of "winners" variable: