Skip to content

Instantly share code, notes, and snippets.

Benjamin Berglund WeeHorse

Block or report user

Report or block WeeHorse

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View git hooks pre-push npm test
npm test
TEST_RESULT=$?
if [ $TEST_RESULT -eq 0 ]
then echo "Tests passed. Committing..."
else echo "Testing your changes has failed! Commit will be aborted."
fi
@WeeHorse
WeeHorse / array-sorting-and-sub-sorting.js
Created Jul 11, 2018 — forked from dfkaye/array-sorting-and-sub-sorting.js
secondary or sub sorting an array in JavaScript
View array-sorting-and-sub-sorting.js
// 29 Sep 2017
// 4 Oct 2017 - add name object example.
// 14 Nov 2017 - pass `a.name, b.name` to `byName()`; rename `test` as `diff`.
// 1 Jan 2018 - made some functions more readable.
// Inspired by post at https://alistapart.com/article/what-i-talk-about-when-i-talk-about-sorting
// which covers an example of sorting by age, but does not ensure items of same age are secondarily
// sorted by name in alphabetical order.
// This snippet shows how to do that whether names are strings or objects with first and last properties.
View form.html
<!DOCTYPE html>
<html>
<body>
<form method="post">
First name:<br>
<input type="text" name="firstname" value="Mickey">
<br>
Last name:<br>
<input type="text" name="lastname" value="Mouse">
@WeeHorse
WeeHorse / example_my_buildings_data_structure.js
Last active Feb 10, 2016
example my buildings data structure
View example_my_buildings_data_structure.js
// see it at https://jsbin.com/mejoke/edit?html,js,console,output
var data = [
{
filename:'england',
path: 'england/',
children:[
{
filename:'1920',
path: 'england/1920/' ,
@WeeHorse
WeeHorse / hangman.js
Created Feb 9, 2016
Hangman jquery version
View hangman.js
// Vi sätter de variabler vi vill ha tillgång till inifrån alla funktioner
var body = $('body');
var displayBox = $('#displayBox');
var bokstavInput = $('#bokstav');
// (tills vidare hårdkodar vi vårt hemliga ord)
var hemligtOrd = 'BRO';
var galgKroppDelar = [];
var doltOrd = [];
var anvandaBokstaver = [];
var maxAntalGissningar;
@WeeHorse
WeeHorse / hangman.js
Last active Feb 9, 2016
Hangman native version
View hangman.js
// Vi sätter de variabler vi vill ha tillgång till inifrån alla funktioner
// (tills vidare hårdkodar vi vårt hemliga ord)
var hemligtOrd = 'BRO';
var galgKroppDelar = [];
var doltOrd = [];
var anvandaBokstaver = [];
var maxAntalGissningar;
function display(str){
@WeeHorse
WeeHorse / findingPeople.js
Last active Feb 9, 2016
WCMS15 Javascript övningsuppgifter 1 vecka 6: Hitta/filtrera personer
View findingPeople.js
// Övningsuppgifter 1 vecka 6:
// Vi har vår data:
// Men lägg till ett par Stockholmare för oss att söka på också:
var list = [
{firstName: 'Benjamin',
lastName: 'Berglund',
age: 46,
city: 'Malmö'},
View block_from_current_node
<?php
// implements hook_block_info
function block_from_current_node_block_info() {
$blocks = array();
$blocks['block_from_current_node'] = array(
'info' => t('Block from current node'),
'cache' => DRUPAL_NO_CACHE
You can’t perform that action at this time.