Skip to content

Instantly share code, notes, and snippets.

@javidjamae
javidjamae / last_month.sql
Last active September 2, 2015 17:35
Select all records created in the last month (MySQL)
select *
from records
where PERIOD_ADD(DATE_FORMAT(NOW(),'%Y%m'), -1) = DATE_FORMAT(created_at,'%Y%m')
@javidjamae
javidjamae / Vagrantfile
Created August 10, 2015 23:18
Vagrantfile for bringing up an Windows / IE virtual server from modern.ie
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Got this file from: https://gist.github.com/andreptb/57e388df5e881937e62a
Vagrant.configure(2) do |config|
config.vm.box = "win7-ie9"
config.vm.box_url = "http://aka.ms/vagrant-win7-ie9"
config.vm.boot_timeout = 500
config.vm.network "forwarded_port", guest: 3389, host: 3389, id: "rdp", auto_correct: true
@javidjamae
javidjamae / .powrc
Last active August 29, 2015 14:25
Use this .powrc file to get pow to play nicely with rvm
if [ -f "$rvm_path/scripts/rvm" ] && [ -f ".ruby-version" ] && [ -f ".ruby-gemset" ]; then
source "$rvm_path/scripts/rvm"
rvm use `cat .ruby-version`@`cat .ruby-gemset`
fi
@javidjamae
javidjamae / gist:0587e2689fccfa2a2e15
Last active August 29, 2015 14:24
Using pow to access Apache on a Vagrant virtual server

This is a much better approach than using Vagrant Hostmanager because you don’t have to worry about polluting your /etc/hosts files on the host or the guest machines. Both the host and the guest machine just treat the guest machine like it’s ‘your-hostname.dev’.

  1. Install pow

    brew install pow
    
  2. Create the port proxy (pow.cx/manual.html#section_2.1.4)

    echo http://127.0.0.1:3333 > ~/.pow/your-hostname
  3. Add the following to your Vagrantfile

    config.vm.network :forwarded_port, guest: 80, host: 3333
    config.vm.hostname = "your-hostname.dev"
    
  4. Create your apache configuration

@javidjamae
javidjamae / gist:3cf910c025e2d33cb8cc
Created July 2, 2015 23:53
Console command to determine whether jQuery has loaded properly
jQuery(document).ready(function(){ alert("hi"); })
<html>
<head>
<script src="https://rawgit.com/javidjamae/3cfb528a618fa4a1c856/raw/ce98069043ab687ab0982707ec7d9d309e2d184e/shim.js" async></script>
</head>
<body>
This is the HTML for <a href="http://stackoverflow.com/questions/30852198/how-can-i-make-an-inserted-javascript-load-before-domcontentloaded">this question</a> on Stackoverflow.
<table>
<tr><td>Some big useless table to slow down DOM rendering</td></tr>
<tr><td>Some big useless table to slow down DOM rendering</td></tr>
(function(){
var scriptTag = document.createElement('script');
scriptTag.type = 'text/javascript';
scriptTag.src = 'https://rawgit.com/javidjamae/a6945382f6d30c46ab5a/raw/7229b5ce14566b9658675dd1c8bf8a45bb0fb65a/second.js';
scriptTag.async = true;
document.getElementsByTagName('head')[0].appendChild(scriptTag);
})();
@javidjamae
javidjamae / gist:3badec9a9c304de07547
Created May 11, 2015 16:47
Verifying I am +javidjamae on my passcard. https://onename.com/javidjamae
Verifying I am +javidjamae on my passcard. https://onename.com/javidjamae
@javidjamae
javidjamae / gist:0062c9ec3685b04a3e46
Created April 28, 2015 06:36
Console output when I try to bring up wordpress with Docker
11:09:28 ~/workspace/docker/hello-wordpress$ docker-compose up
Recreating hellowordpress_db_1...
Recreating hellowordpress_wordpress_1...
Attaching to hellowordpress_db_1, hellowordpress_wordpress_1
db_1 | 150428 6:09:34 [Note] InnoDB: Using mutexes to ref count buffer pool pages
db_1 | 150428 6:09:34 [Note] InnoDB: The InnoDB memory heap is disabled
db_1 | 150428 6:09:34 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
db_1 | 150428 6:09:34 [Note] InnoDB: Memory barrier is not used
db_1 | 150428 6:09:34 [Note] InnoDB: Compressed tables use zlib 1.2.7
db_1 | 150428 6:09:34 [Note] InnoDB: Using Linux native AIO