Skip to content

Instantly share code, notes, and snippets.

View lukelex's full-sized avatar

Lukas Alexandre lukelex

View GitHub Profile
@lukelex
lukelex / volume.sh
Last active December 19, 2021 12:11
Wired multiple style notifications
notify-send -a Volume \
-i /usr/share/icons/FontAwesome-6/light/512x512/all/volume.png \
-h int:value:35 \
-h string:wired-tag:volume \
"35%"
@lukelex
lukelex / janus.rb
Last active August 29, 2015 14:21
Rack authentication middleware
module Middlewares
class Janus
def initialize(app)
@app = app
end
def call(env)
auth_data = auth_for env
if auth_data[:auth][:public_key] == 'missing'
class BatcherMiddleware
def initialize(app)
@app = app
end
def call(env)
if env["PATH_INFO"] == "/batch"
request = Rack::Request.new(env.deep_dup)
responses = JSON.parse(request[:requests]).map do |override|
process_request(env.deep_dup, override)
@lukelex
lukelex / dashboard.coffee
Last active August 29, 2015 14:00
Stik - Dashboard example
#= require stik
#= require moment-with-langs
#= require resources/dashboards
#= require charts/daily_visitors
#= require charts/social_performance
#= require charts/popular_tags
stik.controller 'DashboardCtrl', (ctrl) ->
ctrl.action 'RangeSelector', ($template, $courier, tplWrapper) ->
startDateField = $template.querySelector '#start_date'
@lukelex
lukelex / edit_profile.coffee
Last active August 29, 2015 13:58
StikJS refactoring example
$("#user_picture").change ->
userPictureFileName = $(this).val().split('\\').pop();
$("#user_picture_text").html(userPictureFileName)
files = this.files
reader = new FileReader()
reader.readAsDataURL(files[0])
reader.onloadend = ->
$("#profile_pic").css("background-image", "url(" + this.result + ")")
$("#user_cover_photo").change ->
@lukelex
lukelex / gist:9078128
Created February 18, 2014 19:28
ValkyrJS - Form validations that doesn't suck!

#ValkyrJS - Form validations that doesn't suck!

All existing client-side validation libraries suffer from at least one of these problems, an awful API, heavy dependencies or low extensibility.

ValkyrJS comes to rescue you on your HTML forms judgment by allowing you to extend your validations with new independent, inherited or composed rules. And all that with a really simple and straight forward API.

@lukelex
lukelex / gist:9078124
Created February 18, 2014 19:28
StikJS - From jQuery hell to pluggable components

#StikJS - From jQuery hell to pluggable components

Libraries like MooTools and jQuery are excellent solutions for the problem they try to solve. But your JS codebase can get pretty hairy very easily since they are only meant to touch the DOM and not organizing and testing your code.

This is the story of how I refactored a project out the jQuery code jungle into a testable and reusable codebase by building a JavaScript client-side framework that supports server-side rendering.

@lukelex
lukelex / gist:9078013
Created February 18, 2014 19:23
Unit Acceptance tests with Seeren

#Unit Acceptance tests with Seeren

The way we build and structure our Views are fundamentally wrong. Views should be composed of multiple interdependent pieces, or components if you will, that when assembled together will work as expected.

Seeren was built to support the creation process behind this idea. Where you should develop and test your view's look & feel, behavior and assertiveness, as units and later on put them together as whole.

@lukelex
lukelex / Lab.js
Last active January 4, 2016 10:38
Stik.js test setup experiments
stik.controller("AppCtrl", "List", function($template, CustomFunc){});
var lab = new stik.Lab({
// string or nodeElm
env: "<div data-controller=\"AppCtrl\" data-action=\"List\">...</div>",
// controller or behavior
type: "controller",
name: "AppCtrl",
action: "List",
injection: {
[
{
"matches": [
{
"id": null,
"player_1": {
"id": 1,
"name": "Jan-Ove Waldner",
"points": 99,
"club": "sweden"