Skip to content

Instantly share code, notes, and snippets.

@cmpscabral
cmpscabral / _mixins.scss
Created April 14, 2016 09:57
media queries for retina displays
/* @2x Images (Pixel Ratio of 1.25+) */
@mixin image-2x($image, $width, $height) {
@media only screen and (min--moz-device-pixel-ratio: 5/4),
only screen and (-o-min-device-pixel-ratio: 5/4),
only screen and (-webkit-min-device-pixel-ratio: 1.25),
only screen and (min-device-pixel-ratio: 1.25),
only screen and (min-resolution: 1.25dppx) {
background-image: url($image);
background-size: $width $height;
}
@cmpscabral
cmpscabral / gist:65b0bd6428c2e2b11a18096a9631375f
Created April 6, 2016 16:23
redirect .dev domains to virtual machine
# Install dnsmasq
$ brew install dnsmasq
# Copy the default configuration file.
$ cp $(brew list dnsmasq | grep /dnsmasq.conf.example$) /usr/local/etc/dnsmasq.conf
# Copy the daemon configuration file into place.
$ sudo cp $(brew list dnsmasq | grep /homebrew.mxcl.dnsmasq.plist$) /Library/LaunchDaemons/
# Start Dnsmasq automatically.
<?php
$start_dir = 'whatever'; // Starting directory name no trailing slashes.
$perms['file'] = 0644; // chmod value for files don't enclose value in quotes.
$perms['folder'] = 0755; // chmod value for folders don't enclose value in quotes.
function chmod_file_folder($dir) {
global $perms;
$dh=@opendir($dir);
@cmpscabral
cmpscabral / gist:f786417f36e5adee8f2d
Created March 26, 2016 12:52
list files by modified date tree
tree -ifDt --timefmt=%F
@cmpscabral
cmpscabral / firstLast.sql
Created March 22, 2016 13:28 — forked from mrclay/firstLast.sql
MySQL: Extract last and first name(s) from a full "name" field (for Elgg)
SELECT
-- Assumed to be trimmed
name
-- Does name contain multiple words?
,(LOCATE(' ', name) = 0) AS hasMultipleWords
-- Returns the end of the string back until reaches a space.
-- E.g. "John Doe" => "Doe"
-- E.g. "Francis Scott Key" => "Key"
@cmpscabral
cmpscabral / gist:780c597675c3469db870
Created March 13, 2016 23:02
find files older than x time
find $LOCATION -name $REQUIRED_FILES -type f -mmin +360 -delete
@cmpscabral
cmpscabral / gist:5d73aae78dbf7375667a
Created February 29, 2016 22:54 — forked from mtigas/gist:952344
Mini tutorial for configuring client-side SSL certificates.

Client-side SSL

For excessively paranoid client authentication.

Using self-signed certificate.

Create a Certificate Authority root (which represents this server)

Organization & Common Name: Some human identifier for this server CA.

openssl genrsa -des3 -out ca.key 4096
openssl req -new -x509 -days 365 -key ca.key -out ca.crt
@cmpscabral
cmpscabral / vpn.sh
Created February 17, 2016 15:57
poor man vpn
ssh -N -D 0.0.0.0:1080 localhost
@cmpscabral
cmpscabral / vagrant_helpers
Created February 3, 2016 10:19
vagrant helpers
alias vssh="cd /Users/miguel/Vagrant/ && vagrant ssh -- -t 'sudo su; cd /home/www/'"
alias vup="cd /Users/miguel/Vagrant/ && vagrant up"
alias vprov="cd /Users/miguel/Vagrant/ && vagrant provision"
alias vrestart="killall -9 ruby; cd /Users/miguel/Vagrant && vagrant halt && vagrant up"
@cmpscabral
cmpscabral / gist:876b31dc40071b7a2bb9
Created January 27, 2016 17:21
maagento tools svn
mkdir -p media/content/images/cms-images
mkdir -p webservice/uploads
rm -f app/etc/use_cache.ser
mkdir -p var/cache var/report var/locks var/log var/session var/logging
mkdir -p media/catalog/product
svn revert webservice/.htaccess
svn revert webservice/.htpasswd
svn revert app/etc/local.xml