Skip to content

Instantly share code, notes, and snippets.

@jlsync
jlsync / trap_focus.js
Created November 26, 2022 08:46 — forked from myogeshchavan97/trap_focus.js
Code for trapping focus inside modal
// add all the elements inside modal which you want to make focusable
const focusableElements =
'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';
const modal = document.querySelector('#exampleModal'); // select the modal by it's id
const firstFocusableElement = modal.querySelectorAll(focusableElements)[0]; // get first element to be focused inside modal
const focusableContent = modal.querySelectorAll(focusableElements);
const lastFocusableElement = focusableContent[focusableContent.length - 1]; // get last element to be focused inside modal
@jlsync
jlsync / selenium-webdriver-cheatsheet.md
Created November 22, 2021 02:58 — forked from guorui9016/selenium-webdriver-cheatsheet.md
Ruby Selenium Webdriver CheatSheet

API workthough

  1. Open a browser

    # start an instance of firefox with selenium-webdriver
    driver = Selenium::WebDriver.for :firefox
    # :chrome -> chrome
    # :ie     -> iexplore
    
@jlsync
jlsync / streaming_controller.rb
Created February 18, 2016 17:18
StreamingController
class StreamingController < ApplicationController
include ActionController::Live
before_filter :require_user
def index
Rails.logger.info "streaming#index"
ActiveRecord::Base.connection_pool.release_connection # current_user already loaded in before filter
@jlsync
jlsync / jscrollTo.js.coffee
Created March 6, 2015 15:47
jscrollTo - scroll page to bring element into view
$ = jQuery
$window = $(window)
methods =
init: (options = {}) ->
return this.each () ->
$this = $(this)
offset = $this.offset()
x = undefined
@jlsync
jlsync / bkeys.js.coffee
Created March 6, 2015 15:43
bkeys - jquery keyboard binding
$ = jQuery
special_codes =
8: "backspace", 9: "tab", 13: "return", 16: "shift", 17: "ctrl"
18: "alt", 19: "pause"
20: "capslock", 27: "esc", 32: "space", 33: "pageup", 34: "pagedown"
35: "end", 36: "home"
37: "left", 38: "up", 39: "right", 40: "down", 45: "insert"
46: "del"
@jlsync
jlsync / jtip.css.scss
Last active August 29, 2015 14:14
Jtip 2011
#jtip {
z-index: 11;
position: absolute;
max-width: 200px;
.arrow {
position: absolute;
top: 0px;
width: 0;
height: 0;
margin: 0;
require 'rspec/autorun'
def get_results(string, s_i, chars, c_i )
finds = []
while i = string.index(chars[c_i], s_i)
if chars[c_i + 1]
if more_finds = get_results(string, i + 1, chars , c_i + 1)
finds += more_finds.map{|a| a.unshift(i)}
else
return nil

Make it real

Ideas are cheap. Make a prototype, sketch a CLI session, draw a wireframe. Discussions around concrete examples, not handy-waving abstractions. Don't say you did something, provide a URL that proves it.

Ship it

Nothing is real until it's being used by a real user. This doesn't mean you make a prototype in the morning and blog about it in the evening. It means you find one person you believe your product will help and try to get them to use it.

Do it with style

@jlsync
jlsync / beans
Created September 20, 2011 13:05 — forked from hookercookerman/beans
class of an instance attributes
class Animal
constructor: (@name) ->
move: (meters) ->
console.log @name + " moved #{meters}m."
class Snake extends Animal
@beans: ->
console.log("I eat beans")
@jlsync
jlsync / prawn_wrapped.rb
Created June 30, 2011 19:01
How to prevent prawn wrap_by_char? charred.pdf
#!/usr/bin/env ruby
require 'rubygems'
require 'prawn'
@pdf = Prawn::Document.new
x = 0
texts = [ "alexander", "the alexander", "the alexander building" ]
texts.each do |text|