Skip to content

Instantly share code, notes, and snippets.

PS1='\[\e[1;36m\][\u@\h \W]\$\[\e[0m\] '
@josephan
josephan / gist:eafeee5b31de84bfa472
Created November 23, 2015 21:28
how to start redis 🐧
redis-server /usr/local/etc/redis.conf
@josephan
josephan / SassMeister-input-HTML.html
Created November 27, 2015 15:26
Generated by SassMeister.com.
<div class="row">
<select>
<option value="hydrogen" class=>hydrogen</option>
<option value="lithium" class=>lithium</option>
<option value="helium" class=>helium</option>
<option value="nitrogen" class=>nitrogen</option>
<option value="carbon" class=>carbon</option>
<option value="oxygen" class=>oxygen</option>
<option value="nitrogen" class=>nitrogen</option>
</select>
/**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
@josephan
josephan / joseph.exs
Last active September 29, 2021 20:00
Recursive implementation of reduce and reverse in Elixir
defmodule Joseph do
@moduledoc """
This is my module for the challenges from Elixir TV episode 6
"""
@doc """
Reduces a list to a single value from running a function.
Returns an numeric value.
@josephan
josephan / MainPage.cs
Created November 11, 2016 15:27
react-native-device-info for React Native Windows
using ReactNative;
using ReactNative.Modules.Core;
using ReactNative.Modules.RNDeviceInfo;
using ReactNative.Shell;
using System.Collections.Generic;
namespace AwesomeProject
{
class MainPage : ReactPage
{
# Programming Phoenix Version: P1.0 (April 2016)
# I have the following changeset for my User model:
def changeset(model, params \\ :empty) do
model
|> cast(params, ~w(name username), [])
|> validate_length(:username, min: 1, max: 20)
end
# but I get the following deprecation warning
@josephan
josephan / mix.md
Created June 21, 2017 05:50
Dependency issues
  defp deps do
    [{:phoenix, "~> 1.2.1"},
     {:phoenix_pubsub, "~> 1.0"},
     {:phoenix_ecto, "~> 3.0"},
     {:postgrex, ">= 0.0.0"},
     {:phoenix_html, "~> 2.6"},
     {:phoenix_live_reload, "~> 1.0", only: :dev},
     {:gettext, "~> 0.11"},
 {:cowboy, "~&gt; 1.0"},
@josephan
josephan / lecture1.ex
Last active July 17, 2017 02:21
Computer Science 61A - Lecture 1: functional programming 1
defmodule Lecture1 do
def add(list), do: add(list, 0)
defp add([h | t], acc), do: add(t, acc + h)
defp add([], acc), do: acc
def mult(list), do: mult(list, 1)
defp mult([h | t], acc), do: mult(t, acc * h)
defp mult([], acc), do: acc
end
@josephan
josephan / game_of_life.rb
Created July 29, 2017 02:52
Conway's Game Of Life
class GameOfLife
attr_reader :height, :width
def initialize
@board = {
[10,10] => true,
[10,11] => true,
[10,12] => true,
}
@height = 40