Skip to content

Instantly share code, notes, and snippets.

View mvanduijker's full-sized avatar
👀
👨‍👩‍👦‍👦 💻 🎸

Mark van Duijker mvanduijker

👀
👨‍👩‍👦‍👦 💻 🎸
  • The Netherlands
View GitHub Profile
@SerhiiKozachenko
SerhiiKozachenko / repository.js
Created August 6, 2013 21:54
Mongoose odm and repository pattern.
var mongoose = require('mongoose');
var repository = function (modelName) {
var self = this;
self.Model = require('../models/' + modelName);
self.FindById = function (id, cb) {
self.FindOne({
anonymous
anonymous / concerning.rb
Created December 18, 2012 18:00
class Module
# We often find ourselves with a medium-sized chunk of behavior that we'd
# like to extract, but only mix in to a single class.
#
# We typically choose to leave the implementation directly in the class,
# perhaps with a comment, because the mental and visual overhead of defining
# a module, making it a Concern, and including it is just too great.
#
#
# Using comments as lightweight modularity:
@krymen
krymen / phing
Created November 21, 2012 11:16
Phing bash completion
# /etc/bash_completion.d/phing
_phing () {
local cur prev
COMPREPLY=()
buildfile=build.xml
_get_comp_words_by_ref cur prev
[ ! -f $buildfile ] && return 0
@sevos
sevos / README.md
Last active May 9, 2019 16:13
Rails 5.2 + Komponent + Turbolinks + Stimulus

Usage

rails new my_app --rc=template.rc -m template.rb
@taragano
taragano / cloudinary-php-pure_javascript.php
Last active August 1, 2019 06:49
Client side signed uploads with pure Javascript and PHP
<html>
<body>
<h1>Upload to Cloudinary with FormData</h1>
<form action="" method="post" enctype="multipart/form-data" onsubmit="AJAXSubmit(this); return false;">
<fieldset>
<legend>Upload example</legend>
<p>
<label >Select your photo:
<input type="file" name="file"></label>
</p>
@50kudos
50kudos / flashflush.sh
Last active November 3, 2019 02:03
A Bash script that lists all unused css classes in html/haml/erb files for rails project (or maybe others depending on project structure)
#!/bin/bash
cat $(find app/assets/stylesheets/ -type f) |
grep -Eo '\.[a-z]+[a-z0-9_-]*' | sort | uniq | sed s/.// |
while read CSS; do
if ! grep -Erqi "([^(remove|has)]?class[(:|=|[:space:]*=>[:space:]*)]*[[:space:]\W]*[(\"|')]*[-a-z0-9[:space:]]*$CSS|\\.$CSS\b)" app/views/ vendor/assets/ app/assets/javascripts/; then
echo $CSS >> unused.scss;
fi
done
@nerdcave
nerdcave / environment.js
Last active May 11, 2021 12:27
PurgeCSS config for Rails 5 and Webpacker (along with Tailwind CSS and Vue.js, in this case)
// first run:
// yarn add glob-all purgecss-webpack-plugin --dev
/*
config/webpack/environment.js
PurgeCSS configuration for Rails 5 + Webpacker + Tailwind CSS + Vue.js
Optionally, put this in production.js if you only want this to apply to production.
For example, your app is large and you want to optimize dev compilation speed.
*/
@yosukehasumi
yosukehasumi / readme.md
Last active October 22, 2021 15:12
DigitalOcean Rails/Ubuntu/NGINX (16.04) Setup

DigitalOcean Rails/Ubuntu/NGINX (16.04) Setup

  1. Setup
  2. Swapfile
  3. NGINX
  4. ElasticSearch
  5. RVM
  6. Rails
  7. Postgres
  8. Capistrano
@romainl
romainl / deprecation.md
Last active February 24, 2022 02:42
Idiomatic vimrc
@nicolasembleton
nicolasembleton / restart_bluetooth.sh
Last active October 21, 2022 20:10
Restart Bluetooth Daemon on Mac OS X without restarting
#!/bin/bash
sudo kextunload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport
sudo kextload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport