Skip to content

Instantly share code, notes, and snippets.

View xbill82's full-sized avatar

Luca Marchesini xbill82

  • Kaliop
  • Montpellier, France
View GitHub Profile
@xbill82
xbill82 / convert.sh
Created May 29, 2022 16:45
Recursively convert FLAC files to AAC using ffmpeg
#!/bin/bash
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")
FILES=$(find . -type f -name '*.flac')
for f in $FILES
do
ffmpeg -i $f -c:a aac "${f%.flac}.aac" < /dev/null
@xbill82
xbill82 / MinimumViableToken.sol
Created September 7, 2017 15:13
Minimum Viable Token
contract MyToken {
/* This creates an array with all balances */
mapping (address => uint256) public balanceOf;
/* Initializes contract with initial supply tokens to the creator of the contract */
function MyToken(
uint256 initialSupply
) {
balanceOf[msg.sender] = initialSupply; // Give the creator all initial tokens
}
@xbill82
xbill82 / publisher.js
Created April 4, 2016 09:54
Kuzzle SDK 101
var Kuzzle = require('kuzzle-sdk');
var kuz = new Kuzzle('http://workshop.challenge.kuzzle.io:7512', {defaultIndex: 'klack'});
kuz.dataCollectionFactory('messages').publishMessage({
hello: "world"
});
@xbill82
xbill82 / GigStore.js
Last active August 29, 2015 14:18
Store and Promises
define(['require', 'marionette', 'App', 'collections/Gigs'],
function (require) {
'use strict';
var App = require('App'),
Marionette = require('marionette'),
Gigs = require('collections/Gigs');
var GigStore = Marionette.Controller.extend({
@xbill82
xbill82 / v_btn.js
Last active August 29, 2015 14:17
Simple eventful interface development in Marionettejs
define(['require', 'backbone.marionette', 'handlebars',
'constants/events', 'text!../templates/v_btn.html',
'css!../styles/buttons.css'],
function (require) {
'use strict';
var Backbone = require('backbone');
var Marionette = require('backbone.marionette');
var Handlebars = require('handlebars');
var Events = require('constants/events');
@xbill82
xbill82 / m_article.js
Created March 27, 2015 13:36
Home-made One-to-many relationship in Backbonejs
define(['require', 'backbone', 'collections/c_tags'], function(require) {
"use strict";
var Backbone = require('backbone');
var TagsCollection = require('collections/c_tags');
return Backbone.Model.extend({
tagsCollection: null,
url: function() {
@xbill82
xbill82 / Gruntfile.js
Last active August 29, 2015 14:17
Component-specific Styling (and theming) with LESS and Gruntjs
build: {
options: {
paths: [ // Where to look for files to @import
"app/styles/"
]
},
files: [
// @see http://gruntjs.com/configuring-tasks#building-the-files-object-dynamically
{
expand: true, // Enable dynamic expansion.
@xbill82
xbill82 / custom.map.js
Last active August 29, 2015 14:17
Intercepting dependency with RequireJS
define({
map:{
'*': { 'nav': 'custom/header/nav.custom' }
}
});
@xbill82
xbill82 / CharLimit.js
Last active August 29, 2015 13:56
JS Text-field character limiter (jQuery plugin)
(function($) {
$.fn.extend( {
limiter: function(limit, elem) {
$(this).on("keyup focus", function() {
setCount(this, elem);
});
function setCount(src, elem) {
var chars = src.value.length;
if (chars > limit) {
src.value = src.value.substr(0, limit);
@xbill82
xbill82 / veryFuzzyMatch.php
Last active August 29, 2015 13:56
Very fuzzy word-by-word match
/**
* Matches a string over the other in a fuzzy word-by-word fashion.
* The needle matches the haystack if the haystack contains all the words
* of the needle in any order.
*
* @param String $haystack The string to search in.
* @param String $needle The string that has to be searched for in the
* haystack.
* @return Boolean true if the needle matches the haystack, false
* otherwise.