Skip to content

Instantly share code, notes, and snippets.

View simonewebdesign's full-sized avatar
🇺🇦
💙 💛

Simone Vittori simonewebdesign

🇺🇦
💙 💛
View GitHub Profile
$("a").on("click", function(e){
return false;
/* in theory its just like:
* e.preventdefault();
* e.stopImmediatePropagation();
* but this is true only when you are using jQuery.
* * * * * * * * * * * * * * * * * * * * * * * * */
}
JSONObject o = new JSONObject();
JSONArray a = new JSONArray();
try {
o.put("foo", "bar");
o.put("bool", false);
a.put(1, 123.45);
a.put(2, 123);
JSONArray a = new JSONArray();
try {
a.put(new JSONObject().put("foo", "bar"));
a.put(new JSONObject().put("bar", "baz"));
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
@simonewebdesign
simonewebdesign / helloworld.cs
Last active December 14, 2015 16:08
Say "Hello, World!" in C#
class HelloWorld {
static void Main() {
System.Console.WriteLine("Hello, World!");
}
}
@simonewebdesign
simonewebdesign / loop.sh
Last active July 30, 2016 14:16
bash loop through parameters
#!/bin/bash
# loop through parameters
for WORD; do
echo $WORD
done
# another way is:
for i in "$@"
do
@simonewebdesign
simonewebdesign / join_files.sh
Last active December 15, 2015 21:29
Bash script that joins two or more files in a single one.
#!/bin/bash
# Bash utility that joins every file provided as argument
# and outputs a new file called output.txt.
# bash trap function is executed when CTRL+C is pressed
trap quitprogram INT
quitprogram() {
echo -e "CTRL+C Detected!\nExiting..."
exit
@simonewebdesign
simonewebdesign / helloworld.e
Created April 13, 2013 10:29
Say "Hello, World!" in Euphoria
puts(1, "Hello, World!")
@simonewebdesign
simonewebdesign / editor-demo.html
Created April 17, 2013 20:06
How to make a real-time in-browser editor with the HTML5′s contenteditable attribute -
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title contenteditable>Hey, buddy!</title>
<style class="default">
* {
transition: all .5s ease;
}
@simonewebdesign
simonewebdesign / optional_parameters.php
Created April 23, 2013 09:29
Optional parameters in PHP
<?php
function foo() {
$numargs = func_num_args();
echo "Number of arguments: $numargs<br />\n";
if ($numargs >= 2) {
echo "Second argument is: " . func_get_arg(1) . "<br />\n";
}
@simonewebdesign
simonewebdesign / xhr.js
Last active December 16, 2015 17:49
XMLHttpRequest - the standard way
// Full docs: https://developer.mozilla.org/en-US/docs/DOM/XMLHttpRequest
var xhr,
url = "menu.html",
method = "GET";
if (XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xhr = new XMLHttpRequest();
} else {