Skip to content

Instantly share code, notes, and snippets.

Brandon Sueur brandonsueur

Block or report user

Report or block brandonsueur

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@kyleshevlin
kyleshevlin / partialApplication.js
Created Apr 27, 2019
Partial Application via Bind
View partialApplication.js
// Can't use curried functions for some reason?
// Never fear, partial application via the bind() method is here!
const getFromAPI = (baseURL, endpoint, callback) =>
fetch(`${baseURL}${endpoint}`)
.then(res => res.json())
.then(data => callback(data))
// Partially apply the baseURL
const getFromGithub = getFromAPI.bind(null, 'https://api.github.com')
@kigiri
kigiri / aligning-images.md
Created Sep 18, 2018 — forked from DavidWells/aligning-images.md
Guide to aligning images in github readme.md files
View aligning-images.md

Aligning images

left alignment

This is the code you need to align images to the left:

<img align="left" width="100" height="100" src="http://www.fillmurray.com/100/100">
@sdesalas
sdesalas / jwt.server.js
Created Mar 9, 2017
Node JSON Web Token API authentication
View jwt.server.js
// @see https://scotch.io/tutorials/authenticate-a-node-js-api-with-json-web-tokens
// =======================
// get the packages we need ============
// =======================
var express = require('express');
var app = express();
var bodyParser = require('body-parser');
var morgan = require('morgan');
var mongoose = require('mongoose');
@dmh2000
dmh2000 / bcrypt-promise.js
Last active Jul 18, 2019
Using bcrypt with promises to hash a password and then verify it
View bcrypt-promise.js
let bcrypt = require('bcrypt-nodejs');
let password = "hello";
let stored_hash = "";
// first generate a random salt
function genSalt(password) {
return new Promise((resolve,reject) => {
bcrypt.genSalt(10,function(err,salt) {
if (err) {
View UsersController.php
public function add()
{
$user = $this->Users->newEntity();
if ($this->request->is('post')) {
$user = $this->Users->patchEntity($user, $this->request->data);
if ($this->Users->save($user)) {
$this->Flash->success(__('The user has been saved.'));
return $this->redirect(['action' => 'index']);
} else {
$this->Flash->error(__('The user could not be saved. Please, try again.'));
@bloodyowl
bloodyowl / gist:5d8adcf50e890ebafb95
Last active Feb 10, 2019
ES6 tl;dr; for beginners
View gist:5d8adcf50e890ebafb95
// ES6 tl;dr; for beginners
// 1. variables
// `const` & `let` are scoped at the block level
if(true) {
let foo = "bar"
}
foo // ReferenceError
@jhermann
jhermann / git-commit-emojis.md
Last active Jul 23, 2019
Useful emoji for git commit messages
View git-commit-emojis.md

Useful emoji for git commit messages

If you add emoji to your commit messages for a GitHub repo, they become less boring, and you can convey the kind of change you're adding. See the full set of GitHub supported emoji here (also useful for easy copy&paste via a simple click).

Example commit message

The following is a possible scheme to use:

@addyosmani
addyosmani / README.md
Last active Aug 12, 2019 — forked from 140bytes/LICENSE.txt
108 byte CSS Layout Debugger
View README.md

CSS Layout Debugger

A tweet-sized debugger for visualizing your CSS layouts. Outlines every DOM element on your page a random (valid) CSS hex color.

One-line version to paste in your DevTools

Use $$ if your browser aliases it:

~ 108 byte version

@iksose
iksose / restAPI.markdown
Last active May 30, 2019
Creating a REST API using Node.js, Express, and MongoDB
View restAPI.markdown

###Creating a REST API using Node.js, Express, and MongoDB

####Installing Node.js

Go to http://nodejs.org, and click the Install button. Run the installer that you just downloaded. When the installer completes, a message indicates that Node was installed at /usr/local/bin/node and npm was installed at /usr/local/bin/npm. At this point node.js is ready to use. Let’s implement the webserver application from the nodejs.org home page. We will use it as a starting point for our project: a RESTful API to access data (retrieve, create, update, delete) in a wine cellar database.

Create a folder named nodecellar anywhere on your file system. In the wincellar folder, create a file named server.js.

@rahuldass
rahuldass / Perfect Full Page Background Image.md
Last active Mar 8, 2019
Perfect Full Page Background Image #css
View Perfect Full Page Background Image.md

###Perfect Full Page Background Image

We can do this purely through CSS thanks to the background-size property now in CSS3. We'll use the html element (better than body as it's always at least the height of the browser window). We set a fixed and centered background on it, then adjust it's size using background-size set to the cover keyword.

CSS

html { 
  background: url(images/bg.jpg) no-repeat center center fixed; 
  -webkit-background-size: cover;
You can’t perform that action at this time.