Skip to content

Instantly share code, notes, and snippets.

View dreamyguy's full-sized avatar
👨‍💻 Code-bending

Wallace Sidhrée dreamyguy

👨‍💻 Code-bending
View GitHub Profile
@dreamyguy
dreamyguy / gimme-some-love.js
Created March 27, 2014 15:28
javascript - gimme some love!
var gimme = (function(){
return {
some : function() {
return window.parent.document.createElement('love');
}
};
})();
gimme.some();
@dreamyguy
dreamyguy / check-if-function-exists.js
Last active August 29, 2015 14:01
Check if function exists, through the console.
// a loose check, to see if object exists
if (something) {
console.log('%c something() is present! ', 'background: #bada55; color: black');
} else {
console.log('%c something() is NOT present! ', 'background: #de1e7e; color: white');
}
// a strict check, object must be a function
if (typeof(something) === 'function') {
console.log('%c something() is present! ', 'background: #bada55; color: black');
@dreamyguy
dreamyguy / inject-script.js
Created September 11, 2014 10:02
Inject script tag into body, with callback
// this takes into consideration IE7+
// http://msdn.microsoft.com/en-us/library/hh180173%28v=vs.85%29.aspx
function injectjs(url) {
injs = document.createElement('script');
injs.src = url;
injs.type = 'text/javascript';
injs.async = true;
if(injs.addEventListener) {
injs.addEventListener('load', callback, false);
}
@dreamyguy
dreamyguy / cookie-management.js
Created September 11, 2014 10:30
Create, read and erase cookies
@dreamyguy
dreamyguy / randomly-load-functions.html
Last active August 29, 2015 14:07
Load 1 out of N number of javascript functions randomly
<!DOCTYPE html>
<html>
<head>
<title>Random Functions</title>
<meta name="viewport" content="width=device-width, minimum-scale=1, maximum-scale=1">
</head>
<body>
<div id="top" style="height: 400px"></div>
<div id="bottom" style="height: 400px"></div>
<script type="text/javascript">
@dreamyguy
dreamyguy / SassMeister-input.scss
Created January 20, 2015 21:23
Generated by SassMeister.com.
// ----
// Sass (v3.4.9)
// Compass (v1.0.1)
// ----
// set pixel reference base
$pixelBase: 16 !default;
// strip the unit of measure and return it
@function parseInt($n) {
@dreamyguy
dreamyguy / ezinst
Last active September 14, 2015 08:50
ezinst - install perl dependencies easily (as long as one trusts the source)
#!/bin/sh
echo aptitude install "cpan-lib`echo $1|sed -e 's/\\(::\\|\/\\)/-/g'|tr 'A-Z' 'a-z'`-perl"
sudo aptitude install --allow-untrusted --assume-yes cpan-lib`echo $1|sed -e 's/\\(::\\|\/\\)/-/g'|tr 'A-Z' 'a-z'`-perl ||
echo aptitude install "lib`echo $1|sed -e 's/\\(::\\|\/\\)/-/g'|tr 'A-Z' 'a-z'`-perl"
sudo aptitude install --allow-untrusted --assume-yes lib`echo $1|sed -e 's/\\(::\\|\/\\)/-/g'|tr 'A-Z' 'a-z'`-perl
# use example: ezinst Catalyst::View::TT
@dreamyguy
dreamyguy / gulp-run-tasks-in-series.js
Created October 26, 2015 17:22
Running tasks in series, i.e. Task Dependency
// ref: https://github.com/gulpjs/gulp/blob/master/docs/recipes/running-tasks-in-series.md
// ----------- method 1 ----------- //
gulp.task('2', ['1'], function() {
var stream = gulp.src()
// do some concatenation, minification, etc.
.pipe(gulp.dest());
return stream; // return the stream as the completion hint
@dreamyguy
dreamyguy / iTerm tricks
Created December 8, 2013 08:58
iTerm tricks!
::Turn off system bell on iTerm::
iTerm1
Bookmarks > Manage Profiles > Terminal Profiles > Default > Silence Terminal Bell
iTerm2
Preferences > Profiles > Tab:Terminal > Notifications > Silence Bell
@dreamyguy
dreamyguy / install-osx-from-external-drive.md
Last active January 6, 2016 23:34
OSX's fresh install from external media
  • Download the latest OSX from App Store.

    • The installer will open itself after its download. Do not proceed with install - close it!
    • Once downloaded the installer will be available on Applications folder.
  • Run the following command, taking care to rename the OSX version accordingly and to specify the name of the volume (make sure the command is typed in a single line):

sudo /Applications/Install\ OS\ X\ El\ Capitan.app/Contents/Resources/createinstallmedia --volume /Volumes/<name-of-volume> --applicationpath /Applications/Install\ OS\ X\ El\ Capitan.app --nointeraction

  • The prompt will ask for system password...