Skip to content

Instantly share code, notes, and snippets.

View nicolascine's full-sized avatar
🎯
I may be slow to respond.

Nicolás Silva nicolascine

🎯
I may be slow to respond.
View GitHub Profile
@nicolascine
nicolascine / CONCURRENCY.md
Created October 18, 2019 02:24 — forked from montanaflynn/CONCURRENCY.md
Examples of sequential, concurrent and parallel requests in node.js

Concurrency in JavaScript

Javascript is a programming language with a peculiar twist. Its event driven model means that nothing blocks and everything runs concurrently. This is not to be confused with the same type of concurrency as running in parallel on multiple cores. Javascript is single threaded so each program runs on a single core yet every line of code executes without waiting for anything to return. This sounds weird but it's true. If you want to have any type of sequential ordering you can use events, callbacks, or as of late promises.

type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
export function withAppContext<
P extends { appContext?: AppContextInterface },
R = Omit<P, 'appContext'>
>(
Component: React.ComponentClass<P> | React.StatelessComponent<P>
): React.SFC<R> {
return function BoundComponent(props: R) {
return (
https://stackoverflow.com/a/35965451
function truncate (num, places) {
return Math.trunc(num * Math.pow(10, places)) / Math.pow(10, places);
}
Then call it with:
truncate(3.5636232, 2); // returns 3.56
truncate(5.4332312, 3); // returns 5.433
truncate(25.463214, 4); // returns 25.4632
@mixin for-size($range) {
$phone-upper-boundary: 600px;
$tablet-portrait-upper-boundary: 900px;
$tablet-landscape-upper-boundary: 1200px;
$desktop-upper-boundary: 1800px;
@if $range == phone-only {
@media (max-width: #{$phone-upper-boundary - 1}) { @content; }
} @else if $range == tablet-portrait-up {
@media (min-width: $phone-upper-boundary) { @content; }
@nicolascine
nicolascine / trellis-bedrock-sage.sh
Created August 6, 2018 03:39 — forked from jasperf/trellis-bedrock-sage.sh
Setup Trellis with Bedrock Based Site and Sage starters theme using site folder rukn.me (you can add your own folder name and will add a variable asap) in a bash script #roots #wordpress
#!/bin/bash
echo "Setting up Roots Trellis with Bedrock
Requirements
Ansible >= 1.9.2
Virtualbox >= 4.3.10 - Install
Vagrant >= 1.5.4
vagrant-bindfs >= 0.3.1 (Windows users may skip this)
vagrant-hostsupdater
PHP >=5.4
Composer"
@nicolascine
nicolascine / seo.service.ts
Created April 25, 2018 15:43 — forked from kaaboeld/seo.service.ts
Example working service for adding meta tags to <head/> for angular2-universal. Based on http://blog.devcross.net/2016/04/17/angular-2-universal-seo-friendly-website/
import {Injectable,Inject,ElementRef, Renderer} from '@angular/core';
//import { DOCUMENT } from '@angular/platform/common_dom';
import {DOCUMENT} from '@angular/platform-browser';
@Injectable()
export class SeoService {
private _r: Renderer;
private _el: ElementRef;
private _document: any;
/**
@nicolascine
nicolascine / file.html
Created May 8, 2017 20:50 — forked from csdy/file.html
Javascript vendor libraries via CDN with local fallback
<!-- JQUERY -->
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="/js/vendor/jquery-2.0.3.min.js"><\x3C/script>')</script>
<!-- JQUERY UI -->
<script src="//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>
<script>window.jQuery.ui || document.write('<script src="/js/vendor/jquery.ui-1.10.3.min.js"><\x3C/script>')</script>
<!-- JQUERY VALIDATE -->
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.11.1/jquery.validate.min.js"></script>
@nicolascine
nicolascine / chile.json
Created March 1, 2017 13:19
JSON File with regions and communes of Chile (Regiones y comunas de chile)
{
"regions":[
{
"id":"15",
"name":"Región de Arica y Parinacota",
"communes":[
{
"id":"15101",
"name":"Arica"
},
@nicolascine
nicolascine / django_log_settings.py
Last active August 29, 2015 14:27 — forked from st4lk/django_log_settings.py
Django logging settings
# Logging settings for django projects, works with django 1.5+
# If DEBUG=True, all logs (including django logs) will be
# written to console and to debug_file.
# If DEBUG=False, logs with level INFO or higher will be
# saved to production_file.
# Logging usage:
# import logging
# logger = logging.getLogger(__name__)
# logger.info("Log this message")