Skip to content

Instantly share code, notes, and snippets.

View talamaska's full-sized avatar

Zlati Pehlivanov talamaska

View GitHub Profile
@ivosabev
ivosabev / 0 Readme.md
Last active May 12, 2017 08:27
The Hitchhiker's Guide to the Galaxy of React - Sample Code

In a few simple steps we will create an app that has a link with a counter that increases every time we click it.

We will start with very low and rudementary implementation of a store and with each example evolve it to reach a basic Flux and then Redux implementation.

  1. Global variable - single component
  2. Global variable - multiple components
  3. Props
  4. State
  5. Flux
  6. Redux
@ccnokes
ccnokes / preload-example.js
Created February 1, 2017 03:03
Electron preload script
// in preload scripts, we have access to node.js and electron APIs
// the remote web app will not have access, so this is safe
const { ipcRenderer: ipc, remote } = require('electron');
init();
function init() {
// Expose a bridging API to by setting an global on `window`.
// We'll add methods to it here first, and when the remote web app loads,
// it'll add some additional methods as well.
@ChrisChares
ChrisChares / AsyncAwaitGenerator.md
Last active September 30, 2022 13:26
async/await with ES6 Generators & Promises

async/await with ES6 Generators & Promises

This vanilla ES6 function async allows code to yield (i.e. await) the asynchronous result of any Promise within. The usage is almost identical to ES7's async/await keywords.

async/await control flow is promising because it allows the programmer to reason linearly about complex asynchronous code. It also has the benefit of unifying traditionally disparate synchronous and asynchronous error handling code into one try/catch block.

This is expository code for the purpose of learning ES6. It is not 100% robust. If you want to use this style of code in the real world you might want to explore a well-tested library like co, task.js or use async/await with Babel. Also take a look at the official async/await draft section on desugaring.

Compatibility

  • node.js - 4.3.2+ (maybe earlier with
@DevWurm
DevWurm / entry.js
Last active March 4, 2019 15:21
angular-cli Electron configuration
const {app, BrowserWindow} = require('electron')
const path = require('path')
const url = require('url')
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let win
function createWindow () {
// Create the browser window.
@dimitardanailov
dimitardanailov / 01.crazy-towns.md
Last active June 9, 2016 12:05
Front-end Lightning Talks: Object Oriented CSS Framework and Crazy Towns

Crazy Towns

It’s all about the key selector

What determines the impact of a selector is its key selector. The key selector is a very important thing in the world of CSS as browsers read selectors right to left. This means the key selector is the last one before the opening {, for example:

.header ul      { /* ‘ul’ is the key selector */ }
.ul li a        { /* ‘a’ is the key selector */ }
p:last-child { /* ‘:last-child’ is the key selector */ }
@btroncone
btroncone / rxjs_operators_by_example.md
Last active September 14, 2025 16:48
RxJS 5 Operators By Example
@lexmihaylov
lexmihaylov / native-hash.js
Last active January 2, 2018 03:29
Hashing using the native crypto api and native promise api
function arrayBufferToStringAsync( /*ArrayBuffer*/ buffer) {
var reader = new FileReader();
return readAsync(reader, 'Text', new Blob([buffer])).then(function() {
return new Promise(function(resolve, reject) {
resolve(reader.result);
});
});
};
function arrayBufferToHexAsync( /*ArrayBuffer*/ buffer) {
.platform-android4_1 {
/*Any styles for android 4.1*/
}
.platform-android4_3 {
/*Any styles for android 4.3*/
}
.platform-android4_4 {
/*Any styles for android 4.4*/
@antoniocapelo
antoniocapelo / bearerHttpInterceptor
Created February 13, 2015 21:14
AngularJS HTTP Interceptor for Bearer Token Auth Requests
app.factory('BearerAuthInterceptor', function ($window, $q) {
return {
request: function(config) {
config.headers = config.headers || {};
if ($window.localStorage.getItem('token')) {
// may also use sessionStorage
config.headers.Authorization = 'Bearer ' + $window.localStorage.getItem('token');
}
return config || $q.when(config);
},
@addyosmani
addyosmani / README.md
Last active October 2, 2025 12:05 — forked from 140bytes/LICENSE.txt
108 byte CSS Layout Debugger

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