Skip to content

Instantly share code, notes, and snippets.

View pketh's full-sized avatar
🐢
https://kinopio.club

Pirijan pketh

🐢
https://kinopio.club
View GitHub Profile
@pketh
pketh / sequentialAnimation.js
Last active August 29, 2015 13:58
Runs one animation after the first completes
function sequentialAnimation(first, second, triggerClass) {
first.one('webkitAnimationEnd oanimationend msAnimationEnd animationend', function() {
second.addClass(triggerClass);
});
}
// sample usage
sequentialAnimation($('.first-element-with-animation'), $('.element-to-animate-after'), 'classname-which-triggers-animation-on-the-second-element');
@pketh
pketh / mixins.less
Created April 26, 2014 20:34
core mixins
.transition(@time) {
-webkit-transition: all @time;
-moz-transition: all @time;
-o-transition: all @time;
transition: all @time;
}
.line-height(@px) {
line-height: @px;
@rem: unit(@px, rem);
@pketh
pketh / json.swift
Created June 29, 2014 13:43
JSON with Swift
func getJSON(urlToRequest: String) -> NSData{
return NSData(contentsOfURL: NSURL(string: urlToRequest))
}
func parseJSON(inputData: NSData) -> NSDictionary{
var error: NSError?
var boardsDictionary: NSDictionary = NSJSONSerialization.JSONObjectWithData(inputData, options: NSJSONReadingOptions.MutableContainers, error: &error) as NSDictionary
return boardsDictionary
}
@pketh
pketh / git-recent.sh
Created August 28, 2014 15:35
list recent branches
# add me to .bash_profile or .bashrc
alias git-recent="git for-each-ref --count=5 --sort=-committerdate refs/heads/ --format='🌺 %(refname:short)'"
@pketh
pketh / mixins.less
Last active August 29, 2015 14:11
mixins
.border-box() {
box-sizing: border-box;
-moz-box-sizing: border-box;
}
.box-shadow(@style) {
-webkit-box-shadow: @style;
-moz-box-shadow: @style;
box-shadow: @style;
}
@pketh
pketh / capitalize.js
Created January 7, 2015 21:32
Capitalize first letter
function capitalizeFirstLetter(string) {
var firstLetter = string.substring(0, 1);
var newString = firstLetter.toUpperCase() + string.substring(1,string.length);
return newString;
}
@pketh
pketh / background-animations.css
Created January 20, 2015 04:44
animating background colors with css
/* ripped off from ea1.co */
/* (just add vendor prefixes) */
body {
animation: background-animation-cool 5s linear infinite alternate;
}
section:nth-child(2n+1) {
animation: background-animation-warm 5s linear infinite alternate;
}
@pketh
pketh / each type loops.coffee
Created January 31, 2015 17:46
You don't need each, collect or select in Coffeescript
# from http://makandracards.com/makandra/18605-you-don-t-need-each-collect-or-select-in-coffeescript
## each
for item in items
...
## collect / map
ages = (person.age for person in people)
## select / grep
@pketh
pketh / emailvalidation.js
Created March 9, 2015 15:38
basic email validation
function isValidEmail(input) {
var trimmedInput = $.trim(input),
hasSpaces = trimmedInput.indexOf(' ') !== -1, // true if no spaces
matchesBasicEmailPattern = trimmedInput.match(/@.*[.]/);
return matchesBasicEmailPattern && !hasSpaces;
}
@pketh
pketh / rem-sizing
Created April 1, 2015 18:04
easy CSS font sizing
html
font-size: 62.5%
body
font-size: 1.6rem // = 16px