Skip to content

Instantly share code, notes, and snippets.

View adjavaherian's full-sized avatar
✌️
💾 🔧 ⚾️

Amir Djavaherian adjavaherian

✌️
💾 🔧 ⚾️
View GitHub Profile
@adjavaherian
adjavaherian / Analytics.jsx
Last active December 13, 2017 15:33 — forked from fredrick/App-example-test.js
Here's how we have been pre-processing Jest tests for React.js components which require React-Router or Fluxxor.
//./app/modules/Analytics.jsx
var React = require('react');
var Fluxxor = require('fluxxor');
var FluxMixin = Fluxxor.FluxMixin(React);
var paths = require('../helpers/paths');
var Analytics = React.createClass({
displayName: 'Analytics',
mixins: [FluxMixin],
@adjavaherian
adjavaherian / sass-collector.js
Created July 28, 2015 01:53
Webpack plugin to collect different stylesheets.
var ModuleParserHelpers = require('webpack/lib/ModuleParserHelpers');
var NullFactory = require('webpack/lib/NullFactory');
var _ = require('lodash');
var path = require('path');
var sass = require('node-sass');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var ExtractTextPlugin__dirname = path.dirname(
require.resolve('extract-text-webpack-plugin'));
var visited = {};
@adjavaherian
adjavaherian / RouterTest.jsx
Last active February 6, 2022 05:31
A simple React Router for debugging your route configurations
//quickly test the react-router route configurations
//npm i babel
//babel RouterTest.jsx | node
var React = require('react');
var Router = require('react-router');
var Route = Router.Route;
var RouteHandler = Router.RouteHandler;
var DefaultRoute = Router.DefaultRoute;
var NotFoundRoute = Router.NotFoundRoute;
@adjavaherian
adjavaherian / tictactoes.jsx
Created March 15, 2016 19:59
React Tic Tac Toe Example
var TicTacToe = React.createComponent({
getInitialState: function(){
return {
board : [
['', '', ''],
['', '', ''],
['', '', ''],
],
turn: 'x'
@adjavaherian
adjavaherian / cards.js
Created March 17, 2016 00:08
playing card generator
// clubs (♣), diamonds (♦), hearts (♥) and spades (♠)
var cards = [];
var suits = ['♣', '♦', '♥', '♠'];
var numbers = ['A', 'K', 'Q', 'J',
'10', '9', '8', '7',
'6', '5', '4', '3',
'2'
];
new y hardware 51.50
< 7:48:02 PM: echo: M92 X84.06 Y83.88 Z2020.00 E98.80
(old steps value * software move) / hardware move = new steps value
83.88 * 50 / 51.50 = 81.43
< 8:54:16 PM: echo: M92 X84.06 Y81.43 Z2020.00 E98.80
@adjavaherian
adjavaherian / appium_console
Created April 20, 2016 17:40
appium path error log
[debug] [iOSSim] Building bundle path map
[iOS] Error: ENOENT: no such file or directory, scandir '/Users/4m1r/Library/Developer/CoreSimulator/Devices/87A53418-4DB5-43FF-8EF7-170CA6640AFB/data/Containers/Containers/Data/Application'
at Error (native)
{ [Error: ENOENT: no such file or directory, scandir '/Users/4m1r/Library/Developer/CoreSimulator/Devices/87A53418-4DB5-43FF-8EF7-170CA6640AFB/data/Containers/Containers/Data/Application']
cause:
{ [Error: ENOENT: no such file or directory, scandir '/Users/4m1r/Library/Developer/CoreSimulator/Devices/87A53418-4DB5-43FF-8EF7-170CA6640AFB/data/Containers/Containers/Data/Application']
errno: -2,
code: 'ENOENT',
syscall: 'scandir',
path: '/Users/4m1r/Library/Developer/CoreSimulator/Devices/87A53418-4DB5-43FF-8EF7-170CA6640AFB/data/Containers/Containers/Data/Application' },
@adjavaherian
adjavaherian / async_series.js
Created April 20, 2016 21:46
Example of using reduce with promises and closure to create async results in series
// async_series.js
// example of using reduce with promises and closure to create async results in series
var q = require('Q');
var results = [1, 2, 3, 4, 5];
function workCollection(arr) {
return arr.reduce(function(promise, item, index) {
<script type="text/javascript">
(function(){
var timestamp = 0;
var client = new XMLHttpRequest();
var interval = setInterval(setRefresh, 500);
console.log('setting refresh interval id...', interval);
function getTimestamp(callback) {
client.open("HEAD", "http://localhost:8001/archer/dist/app.js", true);
@adjavaherian
adjavaherian / board_checker.js
Created January 18, 2017 18:46
Sudoku Board Checker
// sudoku board checker
function validateSet(row) {
var hash = {};
if(row.length === 9) {
for(var idx = 0; idx < row.length; idx++) {
hash[row[idx]] = row[idx];
}