Skip to content

Instantly share code, notes, and snippets.

View op1ekun's full-sized avatar

Lukasz Piatkowski op1ekun

View GitHub Profile
@op1ekun
op1ekun / 3rd_party_loader.js
Created June 25, 2013 07:27
Using YUI Loader's onProgress callback to load 3rd party libraries as custom modules. Still needs a little bit of tweaking...
var module = {
exports : {}
};
var exports = {};
YUI({
modules : {
'jquery' : {
fullpath : 'http://code.jquery.com/jquery-1.10.1.min.js'
},
@op1ekun
op1ekun / fancy_ prompt.sh
Created August 23, 2013 21:24
Git branch + git status in prompt
function _fancy_prompt {
local RED="\[\033[01;31m\]"
local GREEN="\[\033[01;32m\]"
local YELLOW="\[\033[01;33m\]"
local BLUE="\[\033[01;34m\]"
local WHITE="\[\033[00m\]"
local PROMPT=""
# Working directory
@op1ekun
op1ekun / jasmine_yui_ajax_mock.js
Created October 1, 2013 08:15
How to easily mock ajax calls using Jasmine's spies. Binds on success callback to the custom object to simulate get('responseData') method.
it('test AJAX mock', function() {
spyOn(Y.io, 'request')
.andCallFake(function(url, config) {
console.log('fake ajax', arguments);
var bound = config.on.success.bind({
'get' : function(name) {
if (name === 'responseData') {
return {
@op1ekun
op1ekun / config.js
Created October 20, 2013 15:14
YUI jquery + jquery plugins loader
// LOAD 3rd party libraries as commonJS modules
var module = {
exports : {}
};
var exports = {};
var config = (function() {
var BASE = '//localhost:8888/';
return {
@davatron5000
davatron5000 / Sublime Text Setup.md
Last active April 15, 2023 15:39
A new user's guide to SublimeText 2. Estimated reading time: 2 mins. Estimated workthrough time: 12 minutes.

Make it useful

  • Install Package Control. For SublimeText 2, paste the following in Terminal:
import urllib2,os; pf='Package Control.sublime-package'; ipp = sublime.installed_packages_path(); os.makedirs( ipp ) if not os.path.exists(ipp) else None; urllib2.install_opener( urllib2.build_opener( urllib2.ProxyHandler( ))); open( os.path.join( ipp, pf), 'wb' ).write( urllib2.urlopen( 'http://sublime.wbond.net/' +pf.replace( ' ','%20' )).read()); print( 'Please restart Sublime Text to finish installation')

From here on out, use Package Control to install everything. +Shift+P, then type Install to get a list of installable packages you can 'livesearch through. After installing plugins, they should be running.

@getify
getify / Gruntfile.js
Created October 29, 2013 20:06
shutting down a `forever`-started server when CTRL+C quitting a grunt-watch task
module.exports = function(grunt) {
var path = require("path");
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON("package.json"),
forever: {
options: {
index: path.join(__dirname,"server.js")
@op1ekun
op1ekun / editable.js
Last active December 27, 2015 16:29
How to capture "aui-editable" widget's "stopEditing" only once? The problem was that the "stopEditing" fired every time used clicked outside of the widget (which is not good if you want to send an AJAX request on blur event). Alloy UI v1.0.1
// editable is an aui-widget instance
editable.after('startEditing', function(ev1){
// some code here
// subscribe here, event will fire multiple times,
// but captured only once,
// it will be reattached next time the widget is editted
editable.once('stopEditing', function(ev2) {
// sent AJAX here!
});
@n3dst4
n3dst4 / ConEmu Git Bash.md
Last active October 20, 2024 23:59
My ConEmu / Cmder git bash task config
  1. Open Conemu

  2. Open Settings -> Tasks or go to new tab button -> Setup tasks.

  3. Click + to add a new task

  4. Enter the name as Git Bash or whatever you like

  5. Task parameters:

     /icon "C:\Program Files (x86)\Git\etc\git.ico" /dir "C:\_git"
    
  6. Command:

I feel the need to have a little rant about MooTools and ES7 and the whole 'Array.contains' hoo-hah.

When MooTools came out in 2006, the most popular framework was Prototype. As the name suggests, it extended prototypes, as did MooTools. People still referred to making websites with JavaScript as 'DHTML', there was no trim method on strings, there wasn't even a forEach method on arrays. JavaScript was a crippled language. IE6 ruled the waves.

MooTools, Prototype, Dojo, Base2 - they made the language usable, even fun, to work with. By using an incredible feature of JavaScript, prototypical inheritance, we were able to add features to the language that made it palatable.

Be it simple methods like number.toInt, string.trim, array.forEach, or familiar programming constructs such as Class, MooTools and its ilk took JavaScript from something impossible to work with to something that you could properly use to build awesome sites, and even apps - Microsoft, IE and desktop ruled everything, and the concept of a 'we

@nolanlawson
nolanlawson / protips.js
Last active November 19, 2024 02:40
Promise protips - stuff I wish I had known when I started with Promises
// Promise.all is good for executing many promises at once
Promise.all([
promise1,
promise2
]);
// Promise.resolve is good for wrapping synchronous code
Promise.resolve().then(function () {
if (somethingIsNotRight()) {
throw new Error("I will be rejected asynchronously!");