Skip to content

Instantly share code, notes, and snippets.

View lukeandersen's full-sized avatar
👨‍💻

Luke Andersen lukeandersen

👨‍💻
View GitHub Profile
@lukeandersen
lukeandersen / Bower behind firewall
Created April 4, 2014 03:03
Make bower work behind a firewall and stop getting hanging errors when scaffolding yeoman sites.
git config --global url."https://".insteadOf git://
@lukeandersen
lukeandersen / gist:11371219
Last active August 29, 2015 14:00
Stupidly simple social sharing buttons
<div class="post-share">
<a class="icon-facebook-sign" href="https://www.facebook.com/sharer/sharer.php?u={PAGE URL}"></a>
<a class="icon-twitter-sign" href="https://twitter.com/intent/tweet?url={PAGE URL}&text={PAGE TITLE}}via={SITE NAME}"></a>
<a class="icon-pinterest-sign" href="http://pinterest.com/pin/create/button/?url={PAGE URL}&media={POST IMAGE URL}&description={PAGE TITLE}" title="Pin It"></a>
<a class="icon-google-plus-sign" href="https://plus.google.com/share?url={PAGE URL}"></a>
</div>
<script>
// requires jQuery
$('.post-share a').each(function() {
@lukeandersen
lukeandersen / gist:df02b34353f539722db3
Created July 31, 2014 01:03
No sudo to install packages
sudo chown -R `whoami` ~/.npm
sudo chown -R `whoami` /usr/local/lib/node_modules
sudo chown -R `whoami` /usr/local
@lukeandersen
lukeandersen / gist:ab3381ccb76d25c2196f
Last active August 29, 2015 14:04
Dynamic image galleries
// Dynamic project image galleries
$('.project-item-wrapper').click(function(e) {
e.preventDefault();
// .project-item-wrapper should have the page destination as its link src, this way is JS is disabled the user would still get to the images
var link = $(this).attr('href');
$.ajax({
url: link,
success: function( data ) {
// Switch img src for large displays
$('.rs-img').each(function() {
var baseWidth = 1140;
// get current width
var lgeScrn = $(window).innerWidth();
// activate if width is less than base width
@lukeandersen
lukeandersen / Exists plugin jQuery
Created August 12, 2014 13:00
Exists plugin jQuery
$.fn.exists = function () {
return this.length !== 0;
}
// usage
$('.my-item').exists();
$.ajax({
type: "GET",
dataType: "jsonp",
cache: false,
url: "https://api.instagram.com/v1/users/140572/media/recent/?access_token=6277169.76495e2.ac7aa5ca54094298b10f8b6a527a9ec3", // Get user images
// Get user iD - http://instagram-uid.herokuapp.com/
// "https://api.instagram.com/v1/tags/catwalk/media/recent?client_id=6277169&access_token=6277169.76495e2.ac7aa5ca54094298b10f8b6a527a9ec3", // Get Tagged images
success: function(data) {
for (var i = 0; i < 9; i++) {
$("#instagram").append("<li><a target='_blank' rel='lightbox' href='" + data.data[i].images.standard_resolution.url + "'><img src='" + data.data[i].images.low_resolution.url +"'></img></a></li>");
@lukeandersen
lukeandersen / npm-scripts.js
Created August 7, 2016 23:44
Useful React Native NPM Scripts
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"rc-start": "npm start -- --reset-cache",
"clean": "rm -rf $TMPDIR/react-* && watchman watch-del-all && npm cache clean",
"clean-start": "npm run clean && npm run rc-start",
"fresh-install": "rm -rf $TMPDIR/react-* && watchman watch-del-all && rm -rf ios/build/ModuleCache/* && rm -rf node_modules/ && npm cache clean && npm install",
"fresh-start" : "npm run fresh-install && npm run rc-start",
"tron": "node_modules/.bin/reactotron"
}
@lukeandersen
lukeandersen / numbersOnly.js
Created August 8, 2016 04:33
Numbers only in text input - Angular directive
'use strict';
angular.module('myApp').directive('numbersOnly', function () {
return {
restrict: 'A',
require: 'ngModel',
scope: {
options: '=numbersOnly'
},
link: function (scope, element, attrs, ngModel) {
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->