Skip to content

Instantly share code, notes, and snippets.

View ajace's full-sized avatar

Ace Atienza ajace

  • Cainkade
  • New York, NY
View GitHub Profile
@ajace
ajace / getQueryVariable.js
Created February 21, 2014 16:55
from CSS-Tricks. grab a query value in the uri
function getQueryVariable(variable)
{
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i=0;i<vars.length;i++) {
var pair = vars[i].split("=");
if(pair[0] == variable){return pair[1];}
}
return(false);
}
@ajace
ajace / pinterest
Created October 14, 2014 14:34
Custom Pinterest Button with auto url and auto media
<!-- credit: http://www.brandaiddesignco.com/insights/add-a-custom-pinterest-pin-it-button-to-your-website/ -->
<a href='javascript:void((function()%7Bvar%20e=document.createElement(&apos;script&apos;);e.setAttribute(&apos;type&apos;,&apos;text/javascript&apos;);e.setAttribute(&apos;charset&apos;,&apos;UTF-8&apos;);e.setAttribute(&apos;src&apos;,&apos;http://assets.pinterest.com/js/pinmarklet.js?r=&apos;+Math.random()*99999999);document.body.appendChild(e)%7D)());'><img src='http://www.brandaiddesignco.com/insights/PinIt.png'/></a>
@ajace
ajace / tweet
Created October 14, 2014 16:27
Twitter Tweet Popup
<script>
function tweetIt(event) {
window.twttr=window.twttr||{};
var D=550,A=450,C=screen.height,B=screen.width,H=Math.round((B/2)-(D/2)),G=0,F=document,E;
if(C>A){G=Math.round((C/2)-(A/2))}
var fullLink = 'http://twitter.com/share?url=' + encodeURIComponent(document.URL) + '&text=' + encodeURIComponent(document.title);
window.twttr.shareWin=window.open(fullLink,'','left='+H+',top='+G+',width='+D+',height='+A+',personalbar=0,toolbar=0,scrollbars=1,resizable=1');
E=F.createElement('script');
E.src='https://platform.twitter.com/widgets.js';
F.getElementsByTagName('head')[0].appendChild(E);
@ajace
ajace / jquery-ui-date-validation.js
Last active August 29, 2015 14:21
jquery-ui-date-validation
function(dateText) {
try {
// US format
$.datepicker.parseDate('mm/dd/yy', dateText);
} catch (e) {
alert(e);
// alert user
};
}
function addOrdinalSuffix(number) {
return number+(['st','nd','rd'][( number +'').match(/1?\d\b/)-1]||'th');
}
@ajace
ajace / grayscale_filter
Created July 18, 2013 15:08
Cross-browser grayscale filter
.gray {
-webkit-filter: grayscale(100%);
filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#grayscale"); /* Firefox 10+, Firefox on Android */
-ms-filter: grayscale(100%);
-o-filter: grayscale(100%);
filter: gray; /* IE 6-9 */
}
@ajace
ajace / initial_setup.sh
Last active December 20, 2015 00:59
Setup.sh for Linux Mint 15, Debian
#!/bin/sh
# chmod +x initial_setup.sh
# sudo ./initial_setup.sh
sudo apt-get install dconf-tools
# Themes
mkdir ~/.themes
## Living closer to the edge! Replace source list from testing to unstable (SID) ##
@ajace
ajace / i-mediaqueries.scss
Created July 26, 2013 03:32
ipad and iphone media queries. example use: @media #{$desktop}
$ipad: "only screen and (min-width: 569px) and (max-width: 1024px)";
$ipad-l: "only screen and (min-width: 769px) and (max-width: 1024px)";
$ipad-p: "only screen and (min-width : 481px) and (max-width : 768px)";
$iphone: "only screen and (min-width: 320px) and (max-width: 568px)";
$iphone-l:"only screen and (min-width: 321px) and (max-width: 568px)";
$iphone-p: "only screen and (max-width: 320px)";
$desktop: "only screen and (min-width: 1224px)";
@ajace
ajace / twitter.1.1.php
Created August 5, 2013 14:22
Twitter Api v1.1
public function curl_fetch ( $id, $since ) {
/*** Twitter Api v1.1 ***/
$url = "https://api.twitter.com/1.1/statuses/user_timeline.json";
$count = $this->_app->count;
$sinceUrl = $since != false ? "&since_id={$since}" : '';
$oauth_access_token = $this->_app->oauth_access_token;
$oauth_access_token_secret = $this->_app->oauth_access_token_secret;
$consumer_key = $this->_app->consumer_key;
@ajace
ajace / laravel_paths
Last active December 20, 2015 15:39
Laravel 4 paths
<?php
// /Illuminate/Support/helpers.php
echo app_path();
echo base_path();
echo public_path();
echo storage_path();