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 / 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)
}
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
  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]
<?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> ...
@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 -->
@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 / 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 / osascript debug #snippet
Created March 21, 2014 08:32
Little way to debug applescript. Also see: http://goo.gl/ZEFzdc
display dialog "my variable: " & myVar
@alex-cory
alex-cory / php debug function #snippet
Created March 17, 2014 09:45
Here my little contribution for a simple yet handy debug function. Stolen from the php documentation. :)
<?php
/**
* dbug (mixed $expression [, mixed $expression [, $... ]])
* Author : dcz
* Feel free to use as you wish at your own risk ;-)
*/
function dbug() {
static $output = '', $doc_root;
$args = func_get_args();
if (!empty($args) && $args[0] === 'print') {
@alex-cory
alex-cory / php date #snippet
Created March 17, 2014 02:10
Just in case you forget about your php date formatting!
<?php
// Assuming today is March 10th, 2001, 5:16:18 pm, and that we are in the
// Mountain Standard Time (MST) Time Zone
$today = date("F j, Y, g:i a"); // March 10, 2001, 5:16 pm
$today = date("m.d.y"); // 03.10.01
$today = date("j, n, Y"); // 10, 3, 2001
$today = date("Ymd"); // 20010310
$today = date('h-i-s, j-m-y, it is w Day'); // 05-16-18, 10-03-01, 1631 1618 6 Satpm01
$today = date('\i\t \i\s \t\h\e jS \d\a\y.'); // it is the 10th day.