Skip to content

Instantly share code, notes, and snippets.

@amite
amite / Names.js
Created April 22, 2017 09:16
Names statistics solution
```
var names = ['Alice', 'Bob', 'Tiff', "Sonny", 'Bruce', 'Alice', "Sonny"];
//output shoule be { 'Alice': 2, 'Bob': 1, 'Tiff': 1, 'Bruce': 1 }
var initialValue = {};
var reducer = (names, stats) => {
(!names[stats]) ? names[stats] = 1
: names[stats] = names[stats] + 1;
@amite
amite / combos.js
Created April 20, 2017 15:14
Faker Factories
let faker = require('faker')
const getRandom = (arr) => arr[Math.floor(Math.random()*arr.length)]
const createCombos = (foodNames, foodTypes) => foodNames.map( (item, index) => `${getRandom(foodTypes)} ${item}`)
const foodNames = ['Samosa', 'Sandwich', 'Roll', 'Pattice']
const foodTypes = ['Non Veg', 'Veg', 'Jain']
function Combo() {
return {
@amite
amite / processMovieDetailsResponse.js
Created April 3, 2017 04:25
refactoring a JSON response
function processMovieDetailsResponse(movie) {
const movieDetailTemplate = `
<div class="movie-detail" data-movie-id="${movie.id}">
<p><strong>${movie.original_title}</strong></p>
<img src="https://image.tmdb.org/t/p/w185${movie.poster_path}" />
<p>
<em>Genres:</em>
<ul>
${displayGenres(movie.id, movie.genres)}
</ul>
@amite
amite / webpack.config.js
Created April 3, 2017 03:45
simple webpack config that loads jQuery
const webpack = require('webpack');
const path = require('path');
module.exports = {
entry: './app/src/index.js',
output: {
path: './app/build',
filename: 'bundle.js',
publicPath: '/'
},
@amite
amite / App.jsx
Created March 21, 2017 07:36
Changing text color in react native
export default class App extends React.Component {
render() {
return (
<View style={styles.container}>
<Text>Open up App.js to start working on your app!</Text>
<Text style={styles.bigblue}>Changes you make reload.</Text>
<Text>Shake your phone to open the developer menu.</Text>
</View>
);
}
@amite
amite / readline.js
Created January 27, 2017 06:17
Excerpt from readline source library
function Interface(input, output, completer, terminal) {
if (!(this instanceof Interface)) {
return new Interface(input, output, completer, terminal);
}
this._sawReturnAt = 0;
this.isCompletionEnabled = true;
this._sawKeyPress = false;
this._previousKey = null;
@amite
amite / import.php
Created June 30, 2016 07:53 — forked from lukeholder/import.php
Basic example to import Products and their variants into Craft Commerce
<?php
namespace Craft;
// This file could be placed into your public_html folder and visited to import a cheese product.
$craft = require '../craft/app/bootstrap.php';
$craft->plugins->loadPlugins();
$newProduct = new Commerce_ProductModel();
@amite
amite / index.html
Created March 24, 2016 11:36
jQuery Plugin Sidr
<!-- You need to follow the template of plugin to create html code -->
<!-- The link to show/hide slideout menu -->
<!-- Note href point to the actual slideout menu -->
<header>
<nav>
<ul class="main_menu">
<li class="logo"><a href="#">Aranca</a></li>
<li class="sidr__menu"><a id="simple-menu" href="#sidr"><i class="fa fa-bars"></i></a></li>
<li class="home"><a href="#"><i class="fa fa-home"></i></a></li>
@amite
amite / htaccess.txt
Created November 30, 2015 11:03
basic .htaccess file
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
@amite
amite / SassMeister-input-HTML.html
Created May 10, 2015 15:59
Generated by SassMeister.com.
<div class="page">
<header>
<a class="logo" href="#"><img src="http://app.reminderbear.com/assets/images/panda-bear-large.png"></a>
<h1 class="company-name">Pandas 'R Us</h1>
<nav>
<ul>
<li class="nav-item"><a href="#">Nav 1</a></li>
<li class="nav-item"><a href="#">Nav 2</a></li>
<li class="nav-item"><a href="#">Nav 3</a></li>
<li class="nav-item"><a href="#">Nav 4</a></li>