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 / emails.coffee
Last active August 29, 2015 14:18
validates emails with hooks for doing other things
validateEmail = (email, input) ->
emailPattern = /^[A-Za-z0-9](([_\.\-+]?[a-zA-Z0-9]+)*)@([A-Za-z0-9]+)(([\.\-]?[a-zA-Z0-9]+)*)\.([A-Za-z]{2,})$/i
if emailPattern.test(email)
addSuccessCookie()
return true
else
input.addClass('fail')
return false
addSuccessCookie = () ->
@pketh
pketh / server.rb
Last active August 29, 2015 14:19 — forked from clody69/server.rb
require 'sinatra'
require 'haml'
$users = {'john' => {:roles => [:user] }, 'mike' => {:roles => [:user, :admin] } }
$tokens = {'123' => {:username => 'john', :expires_at => Time.now+60}}
helpers do
def authenticate_user!
@auth_token = auth_token
if $tokens.has_key?(@auth_token) && !$tokens[@auth_token][:expires_at].nil? && $tokens[@auth_token][:expires_at] > Time.now
@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 / conditional evaluation.coffee
Created December 3, 2015 19:01
tests multiple items to see if that item should be excluded
dothis = ->
console.log 'do this'
dothistoo = ->
console.log 'do this too'
dox = ->
console.log 'do x'
text = (x) ->
___ ___ ___
{o,o} {o.o} {o,o}
|)__) |)_(| (__(|
--"-"-----"-"------"-"--
O RLY? YA RLY NO WAI!
@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 / git-recent.sh
Created September 28, 2015 19:42
List my recent git branches
# add this line to your .bash-profile (.bashrc should also work)
# call this in a repo folder with `git-recent`
alias git-recent="git for-each-ref --count=5 --sort=-committerdate refs/heads/ --format='🌺 %(refname:short)'"
@pketh
pketh / jiggle.styl
Created March 15, 2016 15:42
jiggle animation css
.jiggle
animation: jiggle 0.25s 1 ease-out forwards
@keyframes jiggle
0%
transform: rotate(-3deg)
33%
transform: rotate(3deg)
66%
transform: rotate(-3deg)