Skip to content

Instantly share code, notes, and snippets.

View afshinator's full-sized avatar
🏠
Working from home

Afshin Mokhtari afshinator

🏠
Working from home
View GitHub Profile
@afshinator
afshinator / Schevik parser.js
Created May 21, 2021 02:22
A little text file parser to help the good Doctor Schevik out.
const readline = require('readline'); // https://nodejs.org/api/readline.html
const fs = require('fs'); // The stream for readline will be from a file
// Create the object that will read from the stream
const readInterface = readline.createInterface({
input: fs.createReadStream('./data2.txt'), // 🧐 Data filename goes here
// output: process.stdout,
console: false
});
@afshinator
afshinator / machine.js
Last active March 24, 2020 05:10
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="[add your bin description]" />
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
</body>
@afshinator
afshinator / ModulePatterns.js
Last active August 29, 2015 14:01
Javascript Module Patterns - some examples for comparison and contrast
// This one is from
// http://addyosmani.com/resources/essentialjsdesignpatterns/book/#revealingmodulepatternjavascript
var addyRevealingModule = (function () {
var privateVar = "Joe Schmoe",
publicVar = "Howdy stranger!";
function privateFunction() {
console.log( "Name:" + privateVar );
@afshinator
afshinator / Building TheOdinProject on Mac
Last active August 29, 2015 14:01
OdinOnMac-Mavericks10.9.2
## 1st problem:
Bundle install failed with message about Capybara not being able to install.
Had to use homebrew to install Qt. Take a look at:
https://github.com/thoughtbot/capybara-webkit/wiki/Installing-Qt-and-compiling-capybara-webkit
## 2nd problem: postrgres
require 'spec_helper'
# require 'database_cleaner'
require 'capybara-webkit'
feature "Search" do
# before { visit about_path }
describe "Home page" do
it "should not have a searchbox" do
visit root_path
@afshinator
afshinator / gist:9949986
Last active August 29, 2015 13:58
validating Odin's homepage
<h2>HTML Validation Project</h2>
<h3>for <a href="http://www.theodinproject.com/" target="_blank" >The Odin Project</a> frontpage.</h3>
<p>Recently the site went beta. And with that came some extra exposure and attention; an astute comment on Reddit pointed out that the source code had 2 DOCTYPE tags! *Embarrassing.*</p>
<p>Well, <a href="https://github.com/TheOdinProject/theodinproject/pull/36" target="_blank">that was fixed right quick</a>. But it brings up an issue... *how many other little bugaboo's are in the code?* Let's at least fix up the home page and see where that goes.</p>
<p>One of the tools in web dev's utility belt: **HTML Validation** :
it's like <a href="http://en.wikipedia.org/wiki/Lint_(software)" target="_blank">lint </a> for webpages.</p>
@afshinator
afshinator / js-focus-on-functions
Last active January 7, 2021 17:17
Javascript - Focus on Functions
--> Focus on FUNCTIONS IN JAVACRIPT
### Using callbacks in JavaScript (how to pass functions as arguments to other functions)
function doSomethingCool() {
//
}
$('someElement').click( doSomethingCool );
@afshinator
afshinator / OdinOnNitrous
Last active December 31, 2015 19:49
Building TheOdinProject on Nitrous.io-- https://github.com/TheOdinProject/theodinproject --A lot of us are choosing to develop on nitrous because it makes a lot of dev environment issues go away - not all of them though.This gist is a step-by step recipe to follow along with the 'Hacking on the Site Yourself' instructions in the project README. …
Getting THE ODIN PROJECT running on Nitrous.io
(with Postgresql, ...)
- Especially if you have a windows box, fugget-about-it!!! Just use Nitrous and you'll be well enabled.
- Step numbers below correspond to Eriks steps in 'Hacking on the Site Yourself' at:
https://github.com/TheOdinProject/theodinproject
Read those instructions at the same time for context.