Skip to content

Instantly share code, notes, and snippets.

@rizafahmi
rizafahmi / tensorflow_example.js
Created July 24, 2018 14:14
Code example for tensorflow.js
import * as tf from "@tensorflow/tfjs";
// Define a model for linear regression.
const model = tf.sequential();
model.add(tf.layers.dense({ units: 1, inputShape: [1] }));
// Prepare the model for training: Specify the loss and the optimizer.
model.compile({ loss: "meanSquaredError", optimizer: "sgd" });
// Provide some housing data
const express = require('express')
const path = require('path')
const app = express()
// View Engine setup
app.set('views', path.join(__dirname, 'templates'))
app.set('view engine', 'hbs')
app.use(express.static('public'))
@rizafahmi
rizafahmi / prompt_steeef2_setup
Created April 6, 2017 07:18
Prezto Theme based on steeef
#
# A theme based on Steve Losh's Extravagant Prompt with vcs_info integration.
#
# Authors:
# Steve Losh <steve@stevelosh.com>
# Bart Trojanowski <bart@jukie.net>
# Brian Carper <brian@carper.ca>
# steeef2 <steeef2@gmail.com>
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
var pg = require('pg')
var faker = require('Faker') // install using npm install Faker
var conString = "postgres://postgres:5432@localhost/students"
var client = new pg.Client(conString)
client.connect((err) => {
if(err) {
return console.error('could not connect to postgres', err)
var fs = require('fs')
var file = 'test.db'
var exists = fs.existsSync(file)
var sqlite3 = require('sqlite3').verbose()
var db = new sqlite3.Database(file)
// ---------------------------------------
// create the table we'll use later
// ---------------------------------------
@rizafahmi
rizafahmi / ProtocolTester.java
Created March 6, 2016 12:58
Java Network Programming
import java.net.*;
public class ProtocolTester {
public static void main(String[] args) {
String url = "www.bl.ac.id";
testProtocol("http://" + url);
testProtocol("https://" + url);
testProtocol("ftp://" + url);
testProtocol("nfs://" + url);
@rizafahmi
rizafahmi / menus.js
Created August 25, 2015 00:04
Add new telescope view
Telescope.menuItems.removeAll("viewsMenu");
Telescope.menuItems.add("viewsMenu", [
{
route: 'posts_all',
label: 'All',
description: 'All posts'
},
{
route: 'posts_best',
label: 'Best',
iex(16)> str = "riza@elixirdose.com"
"riza@elixirdose.com"
iex(17)> [email, username, host] = Regex.run(~r/(\w+)@([\w.]+)/, str)
["riza@elixirdose.com", "riza", "elixirdose.com"]
iex(18)> email
"riza@elixirdose.com"
iex(19)> username
"riza"
iex(20)> host
"elixirdose.com"
@rizafahmi
rizafahmi / random
Created January 16, 2014 07:26
Using Elixir Module Random in Elixir
defmodule Randomize do
def random(number) do
:random.uniform(number)
end
end
IO.inspect Randomize.random(10)