Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / helloworld.cs
Last active December 14, 2015 16:08
Say "Hello, World!" in C#
class HelloWorld {
static void Main() {
System.Console.WriteLine("Hello, World!");
}
}
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();
}
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);
$("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.
* * * * * * * * * * * * * * * * * * * * * * * * */
}
@simonewebdesign
simonewebdesign / confirmDelete.js
Last active December 12, 2015 04:28
Display a confirm box when the user clicks on the delete link (event delegation).
/* Display a confirm box when the user
* clicks on the delete link.
*/
function confirmDeleteHandler(e) {
e = e || window.event;
var target;
target = e.target || e.srcElement;
if ( target.className.match(/\bconfirmDelete\b/) ) {
if (!confirm('Are you sure?')) {
e.preventDefault();
@simonewebdesign
simonewebdesign / chmod_dir.sh
Created January 29, 2013 11:51
Chmod all files to 664 and folders to 775 of a given directory. First argument is the directory.
# for files
find $1 -type f -print0 | xargs -0 chmod -v 664
# for folders
find $1 -type d -print0 | xargs -0 chmod -v 775
@simonewebdesign
simonewebdesign / helloworld.c
Created December 30, 2012 12:07
Say "Hello, World!" in C
#include <stdio.h>
main()
{
printf("Hello, World!\n");
}
@simonewebdesign
simonewebdesign / index.haml
Created November 22, 2012 12:02
A CodePen by simonewebdesign. CSS 3D Transform - 3D Rotation with perspective
!!!
%html
%head
%title CSS 3D Transform
%body
#wrapper
#test
#test2
#test3
#light