Skip to content

Instantly share code, notes, and snippets.

Guillaume Perrin gperrin01

Block or report user

Report or block gperrin01

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
View async example.js
// Declare the async function
async function addInFourSeconds(x) {
// In 2 seconds, this Promise will be resolved with the value 10
// Nothing else will be executed until these 2 seconds are over
var y = await resolveAfterTwoSeconds(10);
// print 10, since the above Promise has been resolved
console.log(y);
// In 2 seconds, this Promise will be resolved with the value 10
// Nothing else will be executed until these 2 seconds are over
var z = await resolveAfterTwoSeconds(20);
@gperrin01
gperrin01 / hackernews asyncawait.js
Created May 22, 2017
Scrape Hacker News first page - Sample code to show async/await coding
View hackernews asyncawait.js
nick.newTab().then(async (tab) => {
await tab.open("news.ycombinator.com")
await tab.untilVisible("#hnmain") // We make sure we have loaded the page
await tab.inject("../injectables/jquery-3.0.0.min.js") // We're going to use jQuery to scrape
const hackerNewsLinks = await tab.evaluate((arg, callback) => {
const data = []
$(".athing").each((index, element) => {
data.push({
title: $(element).find(".storylink").text(),
url: $(element).find(".storylink").attr("href")
View phantombuster-getting-started-first-extraction.js
// Phantombuster configuration {
"phantombuster command: casperjs"
"phantombuster package: 3"
"phantombuster transform: babel"
"phantombuster flags: save-folder"
import "babel-polyfill"
import Buster from "phantombuster"
View promises_callbacks.js
var text = 'hello';
var url = "https://translate.yandex.net/api/v1.5/tr.json/translate?key=trnsl.1.1.20150703T111847Z.50bb7b40984bcbfe.c87f5b960dc2613c413df68cdced5360645c6f81&lang=en-it&text=";
var translation;
function isCiao (text) {
console.log(text);
text === 'ciao' ? console.log('translation succesful') : console.log('translation FAIL');
}
View Brokerage Rails app - w6d2.md

#Brokerage App - Requirements

Create your own brokerage and map your associations to respect the following hierarchy:
  • Your brokerage can have many clients
  • A client can have many stocks
  • Many clients can have the same stocks so you need to know everyone's holdings (e.g. Bob owns 15 Google Stocks but Joe owns 23 of them)
@gperrin01
gperrin01 / Sinatra App Homework (w5d3).md
Last active Sep 9, 2015
Sinatra App Homework (w5d3)
View Sinatra App Homework (w5d3).md

Sinatra App

Introduction

To practice everything we've learned over the last couple days, your task is to build a full blown Sinatra app from scratch. It should have full CRUD for a single model with a RESTful controller and corresponding views.

What can you make? You're welcome to be creative, but if you need some ideas:

  • An app to help organize your fancy scotch collection
  • An app for a library to know which books are currently lent out
View calc-it.md

Javascript Calculator (without Functions)

Instructions

Create a calculator that takes input from the browser. The calculator should display the results using alert.

The calculator should do the basic arithmetic operations.

Basic Calculator

@gperrin01
gperrin01 / backbone_walkthrough
Created Jun 30, 2015
Basic Backbone Walkthrough - example of a todo app
View backbone_walkthrough
Walkthrough - example of a todo app
w10/d2_todo_app
Note all along - Each time you write things on a new file, link it on the html with a script tag
Create our “seed data” with a few todos that we gather in a collection
On script.js (main js file)
You can’t perform that action at this time.