Skip to content

Instantly share code, notes, and snippets.

@Darep
Darep / .htaccess
Last active April 23, 2024 07:16
PHP CSS&JS auto-versioning function.
# CSS/JS auto-versioning
RewriteEngine On
RewriteRule ^(.*)\.[\d]{10}\.(css|js)$ $1.$2 [L]
@Darep
Darep / no-comments.js
Created May 30, 2016 07:01
Remove all comments from GitHub Pull Request
// Sometimes it's necessary to do a bit of clean-up
Array.prototype.forEach.call(document.querySelectorAll('.js-comment-delete button'), function(el, i) {
el.removeAttribute('data-confirm');
el.click();
});
#!/bin/sh
#
# Diffs the bundles of a branch with master.
#
BRANCH=$1
# Don't build master if we already have it
if [ ! -d "build_master" ]; then
echo 'Building "master" branch bundle...'
@Darep
Darep / Rakefile
Last active January 27, 2018 22:39
Super simple Middleman deploy script, uses Rsync over SSH or plain SCP
SSH_USER = 'test'
SSH_HOST = 'example.com'
SSH_DIR = '/home/test/website/releases'
RSYNC = false
desc "Run the preview server at http://localhost:4567"
task :preview do
system("middleman server")
end
@Darep
Darep / circle.yml
Created November 3, 2017 11:17
utf8mb4 for CircleCI in Rails
database:
override:
- mv config/database.ci.yml config/database.yml
- RAILS_ENV="test" RACK_ENV="test" bundle exec rake db:create db:structure:load ts:configure ts:index ts:start --trace
@Darep
Darep / item.rb
Created January 24, 2013 19:15
Ruby on Rails concern example: making an ActiveRecord item sortable. Adapted from: http://say26.com/show-us-your-production-code-1-concerns
# app/models/item.rb
require 'concerns/sortable'
class Item < ActiveRecord::Base
include Sortable
attr_accessible :title
end
@Darep
Darep / blog.html.erb
Created January 5, 2014 19:20
Old-school numbered pagination for middleman-blog – see http://i.imgur.com/oYa0Cfj.png
<% if paginate && num_pages > 1 %>
<div class="pagination">
<% if prev_page %>
<%= link_to '<i class="icon-arrow-left"></i> Prev', prev_page, class: 'prev page-numbers' %>
<% else %>
<span class="disabled"><i class="icon-arrow-left"></i> Prev</span>
<% end %>
<% for p in 1..num_pages %>
<% if p == page_number %>
@Darep
Darep / components.some-component.js
Created May 12, 2016 13:50
component init on route change?
import Ember from 'ember';
export default Ember.Component.extend({
init() {
this._super(...arguments);
console.log('init!!1');
},
willDestroy() {
console.log('noooo dsetroyer');
<?php
/**
* Encrypts a "secrets.json" file using mcrypt
*
* Usage: php secrets_encrypt.php > secrets.ejson
*/
require(dirname(__FILE__) . '/key.php');
function _secrets_encrypt($string) {
@Darep
Darep / rollbar.js
Last active December 21, 2015 22:29
Use Rollbar (https://rollbar.com/) with Browserify
// Download rollbar.js and rollbar.min.js from:
// http://d37gvrvc0wt4s1.cloudfront.net/js/1/rollbar.js
// http://d37gvrvc0wt4s1.cloudfront.net/js/1/rollbar.min.js
//
// Place them into vendor/ and this code into lib/rollbar.js, or something
(function(w, d) {
w._rollbarParams = {
"server.environment": "production",
"notifier.snippet_version": "2"