Skip to content

Instantly share code, notes, and snippets.

@guibot17
guibot17 / app.get
Created March 21, 2019 04:14 — forked from tmamedbekov/app.get
Simple readdir with express server. NODE.JS
var express = require('express');
var fs = require('fs');
var app = express();
app.get('/logJson', function (req, res) {
const logsFolder = '/folder/path/';
fs.readdir(logsFolder, (err, files) => {
if (err) {
@guibot17
guibot17 / user.js
Created February 22, 2019 04:25 — forked from EtienneR/user.js
XMLHttpRequest RESTful (GET, POST, PUT, DELETE)
// Get all users
var url = "http://localhost:8080/api/v1/users";
var xhr = new XMLHttpRequest()
xhr.open('GET', url, true)
xhr.onload = function () {
var users = JSON.parse(xhr.responseText);
if (xhr.readyState == 4 && xhr.status == "200") {
console.table(users);
} else {
console.error(users);
@guibot17
guibot17 / JSON with JS.md
Created February 21, 2019 06:52 — forked from laurenancona/JSON with JS.md
Access local JSON data with Javascript

What

An updated guide/collection of guides on how to access JSON data with JavaScript

Original Question on Stack Exchange.


Example 1

For reading the external Local JSON file (data.json) using java script

@guibot17
guibot17 / gist:5d352b191dc596d6ec44571695a167ae
Created December 21, 2018 00:26 — forked from e1024kb/gist:41bf38fdb1a2cb19a781
Country - state list in JSON
{
"countries": [
{
"country": "Afghanistan",
"states": ["Badakhshan", "Badghis", "Baghlan", "Balkh", "Bamian", "Daykondi", "Farah", "Faryab", "Ghazni", "Ghowr", "Helmand", "Herat", "Jowzjan", "Kabul", "Kandahar", "Kapisa", "Khost", "Konar", "Kondoz", "Laghman", "Lowgar", "Nangarhar", "Nimruz", "Nurestan", "Oruzgan", "Paktia", "Paktika", "Panjshir", "Parvan", "Samangan", "Sar-e Pol", "Takhar", "Vardak", "Zabol"]
},
{
"country": "Albania",
"states": ["Berat", "Dibres", "Durres", "Elbasan", "Fier", "Gjirokastre", "Korce", "Kukes", "Lezhe", "Shkoder", "Tirane", "Vlore"]
},
@guibot17
guibot17 / README.md
Created April 27, 2018 05:39 — forked from lopspower/README.md
Hexadecimal color code for transparency

Hexadecimal color code for transparency

Twitter

How to set transparency with hex value ?

For example, you want to set 40% alpha transparence to #000000 (black color), you need to add 66 like this #66000000.

All hex value from 100% to 0% alpha:

@guibot17
guibot17 / what-forces-layout.md
Created December 23, 2017 07:17 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Element

Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()
@guibot17
guibot17 / sample.html
Created December 21, 2017 07:58 — forked from guillaumegarcia13/sample.html
Angular 4 ng-template & ng-container with parameters
<ng-template #followingpost let-author="author" let-age="age" let-text="text" let-badge="badge">
<div class="container-fluid">
<div class="card">
<div class="header">
<h4 class="title">{{ author }}</h4>
<p class="category">il y a {{ age }} jours</p>
</div>
<div class="content" [innerHTML]="text">
</div>
@guibot17
guibot17 / snap-to-grid.js
Created December 7, 2017 23:47 — forked from caleb531/snap-to-grid.js
Makes a jCanvas layer draggable along a defined grid
// Available in jCanvas v20.1.0
// The pixel multiple to snap to
var snapToAmount = 40;
// Round the given value to the nearest multiple of n
function nearest(value, n) {
return Math.round(value / n) * n;
}
$('canvas').drawArc({
layer: true,
@guibot17
guibot17 / audio-api-wrapper.ts
Created November 11, 2017 06:36 — forked from devfred/audio-api-wrapper.ts
Typescript: HTML5 Audio Wrapper for angular2
/**
* @class
* @description
* Wrapper for HTML5 audio.
*/
import {Injectable, NgZone} from 'angular2/core';
import {Observer} from 'rxjs/Observer';
import {Observable} from 'rxjs/Observable';
declare var AudioContext:any;
@guibot17
guibot17 / rxjs_operators_by_example.md
Created September 15, 2017 00:59 — forked from btroncone/rxjs_operators_by_example.md
RxJS 5 Operators By Example