Skip to content

Instantly share code, notes, and snippets.

View alex-cory's full-sized avatar
🔥
🤔

Alex Cory alex-cory

🔥
🤔
View GitHub Profile
@alex-cory
alex-cory / gist:10251197
Created April 9, 2014 10:17
Automatic Nerd Tree startup
" Only open nerdtree if no file was specified on startup
function! StartUpNerdtree()
if 0 == argc()
NERDTree
end
endfunction
autocmd VimEnter * call StartUpNerdtree()
@alex-cory
alex-cory / bs3 login modal #snippet
Last active August 29, 2015 14:00
A bootstrap 3 snippet for a login modal.
<a data-toggle="modal" href="#myModal" class="btn btn-primary">Launch modal</a>
<div class="modal" id="myModal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title">Login</h4>
</div>
<div class="modal-body">
@alex-cory
alex-cory / index.php
Last active August 29, 2015 14:02
CSS3 Portfolio Problems
<div class="container">
<div class="row">
<div class="col-xs-6 col-sm-4 col-md-3">
<div id="wrap" class="text-center">
<div class="thumbnail2">
<div class="thumbnail">
<a href="#myModal">
<div class="caption">
<!-- <button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal"> -->
<!-- BEGIN MODAL HERE -->
<?php
# Display errors in production mode
ini_set('display_errors', '0');
error_reporting(E_ALL & E_ERROR);
ini_set('display_errors', 1);
?>
<!DOCTYPE html>
<html lang="en">
<head> ...
  1. Two Sum ===========

Given an array of integers, return indices of the two numbers such that they add up to a specific target.

You may assume that each input would have exactly one solution.

// Input:
var ints = [5, 4, 3, 7, 1]
import React, { Component } from 'react'
import { connect } from 'react-redux'
import { getData, signup } from './actions'
@connect(state => ({
user: state.user // <- this is an example of how you grab the global state in your components
}), dispatch => ({
signup: (username, password) => dispatch(signup(username, password)) // <- you can either do it LIKE THIS
@alex-cory
alex-cory / helpers.js
Created January 19, 2017 04:56
JavaScript helper functions
function includesAll (string, ...values) {
return values.every(el => string.includes(el))
}
function replaceAll (originalString, string2replace, replaceWith) {
return originalString.split(string2replace).join(replaceWith)
}
@alex-cory
alex-cory / alphabetArray.js
Last active July 22, 2017 08:36
Programmatically Generating Alphabet
String.fromCharCode(...Array(123).keys()).slice(97).split('')
@alex-cory
alex-cory / arrayToN.js
Created July 22, 2017 08:42
Generate Array [0, ...., N] Function
// Option 1: [0, ...., N]
var array = length => Array.from({ length }, (_, i) => i)
// Option 2: [0, ...., N]
var array = to => Array.from(Array(to), (_, i) => i)
// Option 3: [1, ....., N]
var array = length => Array.from({ length }, (_, i) => i + 1)
@alex-cory
alex-cory / closest.js
Created July 29, 2017 18:45
Get Closest Number To
var closest = (nums, goal) => nums.reduce((prv, cur) => (
Math.abs(prv - goal) > Math.abs(cur - goal) ? cur : prv
))
closest([-1, 2, 1, -4], 3) // should return 2