Skip to content

Instantly share code, notes, and snippets.

View kosalvann's full-sized avatar

Kosal Vann kosalvann

View GitHub Profile
@kosalvann
kosalvann / hamlhtml5boilerplate.html.haml
Last active August 29, 2015 14:27 — forked from neiled/hamlhtml5boilerplate.html.haml
My haml version of the html 5 boiler plate code
!!! 5
/[if lt IE 7] <html lang="en" class="no-js ie6">
/[if IE 7 ] <html lang="en" class="no-js ie7">
/[if IE 8 ] <html lang="en" class="no-js ie8">
/[if IE 9 ] <html lang="en" class="no-js ie9">
<!--[if (gt IE 9)|!(IE)]><!--> <html lang="en" class="no-js"> <!--<![endif]-->
%head
%meta{:charset => "utf-8"}/
/
Always force latest IE rendering engine (even in intranet) &amp; Chrome Frame
@kosalvann
kosalvann / Simple Tab Content.markdown
Created August 30, 2015 15:27
Simple Tab Content
@kosalvann
kosalvann / largestNumber.js
Last active September 23, 2015 10:51
Define a function findLargestNumber() that takes an argument from a list of numbers as and returns the largest of them. Use the if condition to get the largest number from the list.
// Define a function findLargestNumber() that takes an argument
// from a list of numbers as and returns the largest of them.
// Use the if condition to get the largest number from the list.
// https://jsfiddle.net/3v3LoLrp/
function findLargestNumber(numbers){
var largestNum = 0 ;
for (var i = 0; i <= numbers.length; i++){
if (numbers[i] > largestNum){
largestNum = numbers[i];
!!!5
/[if lt IE 7] <html lang="en" class="no-js ie6">
/[if IE 7 ] <html lang="en" class="no-js ie7">
/[if IE 8 ] <html lang="en" class="no-js ie8">
/[if IE 9 ] <html lang="en" class="no-js ie9">
<!--[if (gt IE 9)|!(IE)]><!--> <html lang="en" class="no-js"> <!--<![endif]-->
%html{lang: 'en'}
%head
<meta http-e­qui­v="­Con­ten­t-Type" conten­t="­tex­t/html" />
@kosalvann
kosalvann / max.js
Last active September 17, 2022 17:42
Define a function max() that takes two numbers as arguments and returns the largest of them. Use the if-then-else construct available in Javascript.
// Define a function max() that takes two numbers as
// arguments and returns the largest of them. Use the
// if-then-else construct available in Javascript.
// https://jsfiddle.net/ryjtyomv/
function max(firstNum, secondNum){
if (firstNum > secondNum) {
console.log(firstNum + " is larger than " + secondNum);
} else {
@kosalvann
kosalvann / vowel.js
Last active July 8, 2023 16:55
Write a function that takes a character (i.e. a string of length 1) and returns true if it is a vowel, false otherwise.
// Write a function that takes a character (i.e. a string of length 1)
// and returns true if it is a vowel, false otherwise.
function isVowel(argument){
var text;
var argument = argument.toLowerCase();
var vowels = (['a', 'e', 'i', 'o', 'u']);
@kosalvann
kosalvann / sum.multiply.js
Created September 23, 2015 10:49
Define a function sum() and a function multiply() that sums and multiplies (respectively) all the numbers in an array of numbers. For example, sum([1,2,3,4]) should return 10, and multiply([1,2,3,4]) should return 24.
// Define a function sum() and a function multiply() that sums and
// multiplies (respectively) all the numbers in an array of numbers.
// For example, sum([1,2,3,4]) should return 10, and
// multiply([1,2,3,4]) should return 24.
// https://jsfiddle.net/a7ukhbdn/
// Set addition
function sum(numbers) {
var total = 0;
for (var i = 0; i < numbers.length; i++) {
@kosalvann
kosalvann / reverse.js
Created September 23, 2015 18:21
Define a function reverse() that computes the reversal of a string. For example, reverse("jag testar") should return the string "ratset gaj".
// Define a function reverse() that computes the reversal of a string.
// For example, reverse("jag testar") should return the string "ratset gaj".
// https://jsfiddle.net/L678qvLy/
function reverse(str) {
var text = '';
for (var i = str.length - 1; i >= 0; i--) {
text += str[i];
continue
@kosalvann
kosalvann / translate.js
Created September 25, 2015 03:06
Represent a small bilingual lexicon as a Javascript object in the following fashion {"merry":"god", "christmas":"jul", "and":"och", "happy":gott", "new":"nytt", "year":"år"} and use it to translate your Christmas cards from English into Swedish.
// Represent a small bilingual lexicon as a Javascript object in
// the following fashion {"merry":"god", "christmas":"jul", "and":"och", "happy":gott", "new":"nytt", "year":"år"}
// and use it to translate your Christmas cards from English into Swedish.
// https://jsfiddle.net/phd824xh/
// Capitalise each word
function capitalise(string) {
return string.charAt(0).toUpperCase() + string.slice(1).toLowerCase();
}
@kosalvann
kosalvann / 0_reuse_code.js
Created April 30, 2016 14:50
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console