Skip to content

Instantly share code, notes, and snippets.

@lelandbatey
lelandbatey / whiteboardCleaner.md
Last active May 20, 2025 13:11
Whiteboard Picture Cleaner - Shell one-liner/script to clean up and beautify photos of whiteboards!

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"

Results

@mrded
mrded / javascript.js
Last active December 30, 2015 01:09
Hipster's code snippets.
// Call method.
var method = (success ? 'start' : 'stop');
obj[method]();
// Concatenation.
['first', 'name'].join(' '); // = 'first name';
['milk', 'coffee', 'suger'].join(', '); // = 'milk, coffee, suger'
// Value by default.
var name = myName || 'No name'; // Returns 'No name' when myName is null or undefined
@nshkuro
nshkuro / setup vpn script
Last active July 26, 2019 04:17
DigitalOcean VPN script. Ubuntu 12.04
#!/bin/bash
echo "Select on option:"
echo "1) Set up new PoPToP server AND create one user"
echo "2) Create additional users"
read x
if test $x -eq 1; then
echo "Enter username that you want to create (eg. client1 or john):"
read u
echo "Specify password that you want the server to use:"
read p
@mrded
mrded / invoke_hook.php
Last active December 25, 2015 19:29
Drupal: example of hook invoking
<?php
$baz = $qux = t('Arguments');
$bar = array();
foreach (module_implements('foo') as $module) {
$bar[] = module_invoke($module, 'foo', $baz, $qux);
}
# module_invoke_all('foo', $baz, $qux);
@refringe
refringe / sendy-server
Last active August 11, 2025 14:38
Nginx configuration file example for Sendy (http://sendy.co/).
server {
listen 80;
listen [::]:80;
server_name domain.com;
autoindex off;
index index.php index.html;
root /srv/www/domain.com/public;
@mrded
mrded / drupal8-reset.sh
Last active December 22, 2015 16:29
Drush script for resetting Drupal 8 sandbox.
#!/bin/bash
DRUPAL_DIR='/Users/mrded/Sites/drupal8'
mysql -uroot -e'DROP DATABASE drupal8; CREATE DATABASE drupal8;'
touch ${DRUPAL_DIR}/sites/default/files/foo
sudo chmod -R 777 ${DRUPAL_DIR}/sites/default/files
rm -rf ${DRUPAL_DIR}/sites/default/files/*
#drush -y -r ${DRUPAL_DIR} site-install standard --account-name=admin --account-pass=admin --sites-subdir=default
@mrded
mrded / drupal7-reset.sh
Last active August 19, 2018 14:39
Drush script for resetting Drupal sandbox.
#!/bin/bash
echo '✩✩✩✩ Update modules ✩✩✩✩'
drush -y up
echo '✩✩✩✩ Reinstall Drupal ✩✩✩✩'
drush -y site-install standard --account-name=admin --account-pass=admin
echo 'Disable modules'
drush -y dis dashboard overlay toolbar
@alex-zige
alex-zige / gist:5795358
Last active June 8, 2023 07:49
Rails Rspec API Testing Notes

Rails Rspec APIs Testing Notes

Folders Structure

  spec
  |--- apis #do not put into controllers folder. 
        |--- your_api_test_spec.rb  
  |--- controllers
  |--- models
  |--- factories
 |--- views
@jhedstrom
jhedstrom / FeatureContext.php
Last active April 5, 2019 10:25
Step-definition for complex node structure (field collection + entity reference).
<?php
/**
* @Given /^I am viewing a product with the following related products:$/
*/
public function assertRelatedProducts(TableNode $relatedProducts) {
// First, create a product.
$product = (object) array(
'title' => 'Parent Product',
'type' => 'product',
'uid' => 1,
@braidn
braidn / scorched.rb
Last active December 15, 2015 08:39
just playing with a little / new framework
class MyApp < Scorched::Controller
render_defaults.merge!(
engine: :haml,
layout: :index
)
#redirect after a 404 error
after status:404 do
redirect('/')
end
middleware << proc {