Skip to content

Instantly share code, notes, and snippets.

💭
💾 🔧 ⚾️

Amir Djavaherian adjavaherian

💭
💾 🔧 ⚾️
Block or report user

Report or block adjavaherian

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View board_checker.js
// 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];
}
View refresh_app.html
<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 / async_series.js
Created Apr 20, 2016
Example of using reduce with promises and closure to create async results in series
View async_series.js
// 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) {
@adjavaherian
adjavaherian / appium_console
Created Apr 20, 2016
appium path error log
View appium_console
[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' },
View simple_belt_mod_update.txt
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 / cards.js
Created Mar 17, 2016
playing card generator
View cards.js
// clubs (♣), diamonds (♦), hearts (♥) and spades (♠)
var cards = [];
var suits = ['', '', '', ''];
var numbers = ['A', 'K', 'Q', 'J',
'10', '9', '8', '7',
'6', '5', '4', '3',
'2'
];
@adjavaherian
adjavaherian / tictactoes.jsx
Created Mar 15, 2016
React Tic Tac Toe Example
View tictactoes.jsx
var TicTacToe = React.createComponent({
getInitialState: function(){
return {
board : [
['', '', ''],
['', '', ''],
['', '', ''],
],
turn: 'x'
@adjavaherian
adjavaherian / RouterTest.jsx
Last active Oct 7, 2018
A simple React Router for debugging your route configurations
View RouterTest.jsx
//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 / sass-collector.js
Created Jul 28, 2015
Webpack plugin to collect different stylesheets.
View sass-collector.js
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 / Analytics.jsx
Last active Dec 13, 2017 — 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.
View Analytics.jsx
//./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],
You can’t perform that action at this time.