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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- 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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"regions":[ | |
{ | |
"id":"15", | |
"name":"Región de Arica y Parinacota", | |
"communes":[ | |
{ | |
"id":"15101", | |
"name":"Arica" | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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") |