Skip to content

Instantly share code, notes, and snippets.

@connor11528
connor11528 / app.js
Created April 2, 2015 18:31
Code to make a leaflet.js map the Angular Way. Comes from a tutorial: http://connorleech.ghost.io/how-to-use-the-angular-leaflet-directive/
var app = angular.module("mymapingapp", [
"leaflet-directive"
]);
app.controller('MainCtrl', ['$scope', function($scope) {
// make map
angular.extend($scope, {
san_fran: {
lat: 37.78,
lng: -122.42,
@connor11528
connor11528 / linkedlist.js
Created April 10, 2015 03:05
linked list javascript implementation
var Node = function(value){
var node = {};
node.value = value;
node.next = null;
return node;
};
var LinkedList = function(){
@connor11528
connor11528 / bandpage-getArtist.js
Last active August 29, 2015 14:24
Attempting to get information about Kelly Clarkson from the BandPage API
// Bandpage API
var BANDPAGE_APP_ID = '4945-------953728';
var BANDPAGE_API_KEY = '5ae045d8e3-------92177c69';
var BANDPAGE_API_SECRET = '055837ad8400---------058e7d1e3';
var BANDPAGE_BASE = 'https://api-read.bandpage.com/';
var request = require('request');
var kelly_clarkson_bid = '12334995322703872';
@connor11528
connor11528 / webDriverIntro.js
Created August 20, 2015 01:33
script to scrape songkick for upcoming concerts in the bay area
// script to get "Popular tickets in SF Bay Area" from songkick
//======
var fs = require('fs');
var cheerio = require('cheerio');
var webdriverio = require('webdriverio');
var options = { desiredCapabilities: { browserName: 'chrome' } };
var client = webdriverio.remote(options);
var outputPath = './results.json';
@connor11528
connor11528 / scraper.js
Created August 22, 2015 18:43
nutella-scraping-solution
var got = require('got');
var cheerio = require('cheerio');
var redditUrl = 'http://web.archive.org/web/20120216223019/http://www.reddit.com/r/science/';
var nextUrl = 'https://web.archive.org/web/20030910064848/http://www.ed.gov/index.jhtml';
got(redditUrl, function(err, html){
var $ = cheerio.load(html);
@connor11528
connor11528 / S3_public_policy.json
Last active September 6, 2017 16:45
Paste in this S3 bucket permission policy for our WildRydes AWS application. The website is hosted on the internet so we want it publicly accessible to everyone!
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::YOUR_BUCKET_NAME/*"
}
]
@connor11528
connor11528 / ssl-redirect.html
Created October 18, 2017 19:59 — forked from konklone/ssl-redirect.html
Force a quick redirect to HTTPS on Github Pages for your domain (and only your domain)
<script>
var host = "YOURDOMAIN.github.io";
if ((host == window.location.host) && (window.location.protocol != "https:"))
window.location.protocol = "https";
</script>
@connor11528
connor11528 / app\Http\Controllers\AdminController.php
Created March 1, 2018 13:48
Admin controller that invokes custom middleware to protect a route
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class AdminController extends Controller
{
public function __construct()
{
$this->middleware('auth');
@connor11528
connor11528 / linearSearch.js
Created December 22, 2017 23:20
The linear search algorithm implemented in Javascript
function linearSearch(array, toFind){
for(let i = 0; i < array.length; i++){
if(array[i] === toFind) return i;
}
return -1;
}
@connor11528
connor11528 / binarySearch.js
Last active May 20, 2018 20:15
Binary search for finding an element's index in a sorted array using Javascript.
function binarySearch(arr, target) {
let left = 0;
let right = arr.length - 1;
while (left <= right) {
const mid = left + Math.floor((right - left) / 2);
if (arr[mid] === target) {
return mid;
}
if (arr[mid] < target) {
left = mid + 1;