Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

xullnn

🎯
Focusing
View GitHub Profile
View car_fitlering_app.js
var app = (function() {
var cars = [
{ make: 'Honda', image: 'images/honda-accord-2005.jpg', model: 'Accord', year: 2005, price: 7000 },
{ make: 'Honda', image: 'images/honda-accord-2008.jpg', model: 'Accord', year: 2008, price: 11000 },
{ make: 'Toyota', image: 'images/toyota-camry-2009.jpg', model: 'Camry', year: 2009, price: 12500 },
{ make: 'Toyota', image: 'images/toyota-corrolla-2016.jpg', model: 'Corolla', year: 2016, price: 15000 },
{ make: 'Suzuki', image: 'images/suzuki-swift-2014.jpg', model: 'Swift', year: 2014, price: 9000 },
{ make: 'Audi', image: 'images/audi-a4-2013.jpg', model: 'A4', year: 2013, price: 25000 },
{ make: 'Audi', image: 'images/audi-a4-2013.jpg', model: 'A4', year: 2013, price: 26000 },
];
@xullnn
xullnn / the_longest_sentence.js
Last active Jun 5, 2019
The longest sentence
View the_longest_sentence.js
var longText = 'Four score and seven years ago our fathers brought forth' +
' on this continent a new nation, conceived in liberty, and' +
' dedicated to the proposition that all men are created' +
' equal.' +
' Now we are engaged in a great civil war, testing whether' +
' that nation, or any nation so conceived and so dedicated,' +
' can long endure. We are met on a great battlefield of that' +
' war. We have come to dedicate a portion of that field, as' +
' a final resting place for those who here gave their lives' +
' that that nation might live. It is altogether fitting and' +
@xullnn
xullnn / rot13.js
Created May 5, 2019
Rot13 in Javascript
View rot13.js
const LOWER_START = 97;
const UPPER_START = 65;
const LOWER_END = LOWER_START + 26;
const UPPER_END = UPPER_START + 26;
function newAsciiOf(char) {
var newAscii = char.charCodeAt() + 13;
if (/[a-z]/.test(char) && newAscii >= LOWER_END) {
newAscii = (LOWER_START + (newAscii % LOWER_END));
View revised_nutrition_facts.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<style>
html {
font-size: 23px;
font-family: sans-serif;
font-weight: lighter;
@xullnn
xullnn / nutrition_facts.html
Last active Apr 17, 2019
practice html and css
View nutrition_facts.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<style>
html {
font-size: 32px;
font-family: "Helvetica Black", Helvetica;
}
View halfway_in_ls.md

Halfway in my Launch School journey

I've just finished Database course in Launch School(hereinafter refer as LS), it's about half of its core curriculum. I prefer to call LS as a journey, because life in LS is more than what we do in a traditional "school".

Thanks to Internet

I live in a very small city in China, and I never knew or cared about anything about programming until 28. But thanks to Internet, I met LS. I was deeply drawn by LS's pedagogy. Instead of selling you the course urgently, LS provides a free preparatory course and advises you to make the decision after you've evaluated your feelings about the pre-course and you are agree with their pedagogy.

What I appreciate about LS

@xullnn
xullnn / update_yaml.rb
Created Feb 21, 2019
Try updating a portion of a yaml file
View update_yaml.rb
f = File.open("./example.yaml", "w")
100000.times do |n|
str = "user_#{n}:\n id: #{n}\n score: 0\n"
File.write("./example.yaml", str, mode: "a")
end
def find_position(target, file_obj)
file_obj.pos = file_obj.read =~ Regexp.new(target)
end
@xullnn
xullnn / decipher.rb
Last active Jan 15, 2019
zhuolaobanmimatiaozhan
View decipher.rb
encoded_text = <<-MSG
snmft
ltslcnsnonjhmzemjizfsbjsenijmfsdn
cnfrnfsbtdftonftljnsndnljwjsbz
emndtzsnbfshmjslqjemjljwjsbz
hfndtzonmznmztijonfsluns
efnrnrfczjpjhmjslemtsl
btrjshmzqjczjcnqjifqnfslonfrnmjonjrnijemnxmn
mfnqnftonjqjxmnljemzrnslijrnrfczjwjsbzyfrjsljozkjsllj
dtzcnjwjsxznwfsefteftonzvzxmnqjifsqnzcnfqjgftlznijxmzczjhmjsllzt
@xullnn
xullnn / mango_seller_with_comments.rb
Last active May 4, 2018
mango_seller_with_comments
View mango_seller_with_comments.rb
class Person
attr_accessor :name, :is_seller, :friends
def initialize
@name = ('a'..'z').to_a.sample(5).join.capitalize!
@is_seller = false
@friends = []
end
end
def make_friends(n)
@xullnn
xullnn / knapsack.rb
Last active Apr 27, 2018
the knapsack problem
View knapsack.rb
class Item
attr_accessor :name, :weight, :price
end
class Knapsack
attr_accessor :items, :capacity, :table
def initialize(capacity)
@items = []
@capacity = capacity