A sliding checkbox for representing an on/off toggle in a simple and slick way.
A Pen by Ian McNally on CodePen.
A sliding checkbox for representing an on/off toggle in a simple and slick way.
A Pen by Ian McNally on CodePen.
# | |
# Write a function `wordPair` that for a | |
# given a string, returns the most frequent word pair (word, space, word) | |
# E.g., 'I want to be a part of it New York, New York' -> 'New York' | |
# | |
wordPair = (str) -> | |
getWordPairCounts = (str) -> | |
words = str.replace(/[^a-zA-Z\s]/g, '').split ' ' | |
pairCounts = {} |
function isBalanced(string) { | |
var closers = { | |
'{' : '}', | |
'(' : ')', | |
'[' : ']' | |
} | |
var stack = []; | |
for (var i = 0, l = string.length; i < l; i++) { | |
if (closers[string[i]]) { | |
stack.push(string[i]); |
fizzbuzz = -> | |
for n in [1..100] | |
fizz = if n % 3 is 0 then 'fizz' else '' | |
buzz = if n % 5 is 0 then 'buzz' else '' | |
output = fizz + buzz or n | |
console.log output |
git config --global mergetool.sublime.cmd "subl -w \$MERGED" | |
git config --global mergetool.sublime.trustExitCode false | |
git config --global merge.tool sublime | |
Usage: | |
git mergetool -y |
Configuring Charles to proxy, so you can test localhost on a virtual machine. | |
1. In Charles proxy settings, set a port, i.e., 8889. | |
2. In your VM, modify the local area settings. | |
1. In IE, go to Settings > Connections > LAN Settings | |
2. Under proxy server, select Use a proxy server. | |
3. Under proxy server Address, use your machine's IP. | |
4. Under proxy server Port, use the Charles proxy port, i.e., 8889. | |
3. Turn on proxying in Charles. |
# Only update <input> elements with bound angular models <input ng-model="my model"> on 'blur' event. | |
# Tweaked from a variety of places. | |
app.directive 'updateOnBlur', -> | |
require : 'ngModel' | |
link : (scope, element, attributes, ngModelController) -> | |
element.unbind 'input' | |
element.bind 'blur', -> | |
scope.$apply -> | |
ngModelController.$setViewValue element.val() |
def longest_palindrome str | |
palindromes = [] | |
str.split('').each.with_index do |c, i| | |
0.upto i do |j| | |
# get all substrings up to the current letter | |
chunk = str[j..i] | |
reverse_chunk = chunk.reverse | |
# check if they're a palindrome | |
palindromes << chunk if chunk == reverse_chunk | |
end |