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 / gist:4152195
Created November 27, 2012 03:32
Simple Mobile First @media queries
/*
=============================
# Mobile First @media queries
=============================
*/
/* styles for iphone portrait go up here*/
/* Smartphones (landscape) ----------- */
@media only screen
@pketh
pketh / paragraphs-date.js
Last active December 17, 2015 12:59
Date converter hack for the 'paragraphs' osx static blogging platform. Currently, it only outputs dates in a single format. This hack gives you friendly, flexible formatting.
$(document).ready(function(){
$( ".date" ).each(function( ) {
var month = $(this).text().substring(0,2);
var day = $(this).text().substring(7,9);
var year = $(this).text().substring(9,11);
if (month == 01) {
var month = 'Jan';
@pketh
pketh / parallax.js
Created September 24, 2013 15:50
simple parallax scrolling using jquery
//simple version targetting a position: absolute div
$(window).on("scroll",function(){
$('.target').css({"top" : ( .5 * $(window).scrollTop() ) + 100 })
// the .5 refers to parallax speed (higher is faster)
// the 100 refers to the initial start position offset (higher is further down)
})
// version with additional fading out as you scroll down
@pketh
pketh / gist:7707387
Last active December 29, 2015 17:59
using jquery and easing js, smooth scroll to a specific anchor links
// smooth scroll to a specific section on the same page
function smoothScroll (selector) {
$('html, body').animate(
{
scrollTop: jQuery(selector).offset().top
},
600,
'easeOutCubic', // curves from http://easings.net/
function(){
$('#company').focus();
@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;
}