Skip to content

Instantly share code, notes, and snippets.

View op1ekun's full-sized avatar

Lukasz Piatkowski op1ekun

View GitHub Profile
@op1ekun
op1ekun / jQuery-YUI.js
Created June 20, 2013 23:59
jQuery as a custom YUI module
// version with iframe
YUI.add('dlp-jquery', function(Y) {
// create iframe dynamically to create a sandbox for our script
var myIframe = document.createElement('iframe');
myIframe.id = 'jQueryIframe';
// callback run when the iframe is loaded
myIframe.onload = function() {
console.log('my iframe loaded');
@op1ekun
op1ekun / jQuery-YUI-commonJS.js
Created June 21, 2013 00:11
commonJS approach used to create a custom YUI module
// cheat jQuery that so it uses module exports instead of global variable
// FIXME needs feature detection before defining module
var module = {
exports : {}
}
// version with global module export
YUI.add('dlp-jquery-commonjs', function(Y) {
Y.Get.script('http://code.jquery.com/jquery-1.10.1.min.js', {
@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 {
@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!
});
/**
* Use em or rem font-size in Bootstrap 3
*/
@font-size-root: 14px;
@font-unit: 0rem; // Pick em or rem here
// Convert all variables to em

An ongoing project to catalogue all of these sneaky, hidden, bleeding edge selectors as I prepare my JSConf EU 2012 talk.

Everything is broken up by tag, but within each the selectors aren't particularly ordered.

I have not tested/verified all of these. Have I missed some or got it wrong? Let me know. - A

A friendly reminder that you may need to set this property on your target/selected element to get the styling results you want:

-webkit-appearance:none;

@op1ekun
op1ekun / circle_detection.py
Created February 25, 2016 12:36 — forked from martinsik/circle_detection.py
Circle detection with OpenCV 3.0
import cv2
import time
import math
import numpy as np
capture = cv2.VideoCapture(0)
print capture.get(cv2.CAP_PROP_FPS)
t = 100
w = 640.0