Skip to content

Instantly share code, notes, and snippets.

@Lin4ipsum
Lin4ipsum / machine.js
Last active February 24, 2021 20:14
Generated by XState Viz: https://xstate.js.org/viz
const hungrylMachine = Machine({
id: "hungry",
initial: "fridge",
states: {
fridge: {
on: {
cook: "cook",
order: "order",
go_to_moms_house: "moms"
}
@Lin4ipsum
Lin4ipsum / Linkify.html
Last active October 4, 2015 01:32
Turn comment urls into clickable links
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<title>Linkify Comment Urls</title>
<style>
body {
background-color: #F1F1F1;
font-family: Helvetica;
}
// These two need to be declared outside the try/catch
// so that they can be closed in the finally block.
HttpURLConnection urlConnection = null;
BufferedReader reader = null;
// Will contain the raw JSON response as a string.
String forecastJsonStr = null;
try {
// Construct the URL for the OpenWeatherMap query
@Lin4ipsum
Lin4ipsum / gist:6132129
Created August 1, 2013 14:51
ex/ javascript revealing module pattern
var calculator = function() {
var numbers = [4,2,5,7],
sum = 0
var getSum = function() {
for(var x = 0; x < numbers.length; x++){
sum += numbers[x];
}
return sum;
};
var sayHello = function() {
@Lin4ipsum
Lin4ipsum / tips.css
Created October 5, 2012 17:11
CSS Tips
shadow box
-moz-box-shadow: 3px 3px 5px 6px #ccc;
-webkit-box-shadow: 3px 3px 5px 6px #ccc;
box-shadow: 3px 3px 5px 6px #ccc;
@Lin4ipsum
Lin4ipsum / UglyDuck.html
Created September 17, 2012 04:08
Ugly Duck
<style>
ul {padding:0;}
ul li {
background-repeat: no-repeat;
background-position: top left;
background-image: url('http://hosturl.co.uk/cc/d.png');
line-height: 57px;
padding-left: 70px;
margin: 0px;
list-style: none;
@Lin4ipsum
Lin4ipsum / Celsius_to_fahrenheit_converter.rb
Created August 9, 2012 22:43
Celsius_to_fahrenheit_converter.rb
print "What celsius tempurature would you like convert to farhenheith?"
celsius = gets.chomp.to_i
fahrenheit = (celsius *9/5 + 32)
puts "The result is: #{fahrenheit}"
@Lin4ipsum
Lin4ipsum / EasyLiving.html
Created August 1, 2012 16:48
EasyLiving.html
<style>
p {
border-style: dashed;
border-width: 1px;
border-color: orange;
margin: 0px;
padding-left: 10%;
padding-right: 10%;
text-align: justify;
@Lin4ipsum
Lin4ipsum / Rabbit_Constructor.js
Created June 30, 2012 16:10
Rabbit Constructor in JS
// first we can make the instructor
function Rabbit(adjective) {
this.adjective = adjective;
this.describeMyself = function() {
console.log("I am a " + this.adjective + " rabbit");
};
}
// now we can easily make all of our rabbits
var rabbit1 = new Rabbit("fluffy");
@Lin4ipsum
Lin4ipsum / Taxi_Cab.js
Created June 26, 2012 17:35
Taxi Cab Fare Calculator in JS
// use taxiFare to set tripCost to the cost of your
// ride covering 5 miles at 2 am in the morning
var tripCost = taxiFare(5, 2);
// calculates taxi fare based upon miles traveled
// and the hour of the day in military time (0-23).
var taxiFare = function (milesTraveled, pickupTime) {
var baseFare = 2.50;
var costPerMile = 2.00;
var nightSurcharge = 0.50; // 8pm to 6am, every night