Skip to content

Instantly share code, notes, and snippets.

View finalclass's full-sized avatar

Szymon Wygnański finalclass

View GitHub Profile
@finalclass
finalclass / linux-file-types-association.md
Last active August 6, 2021 09:53
associating file types with apps

How to associate a file type with an app on linux?

You need:

  1. to define an app
  2. to define a mime type
  3. set default

Define an app

@finalclass
finalclass / month-bounds.js
Created August 10, 2018 09:41
Get bounds of a month (beginning of a month and the end of a month)
exports.getBeginningOfMonth = function getBeginningOfMonth(timestamp) {
const d = new Date(timestamp);
return Date.UTC(d.getUTCFullYear(), d.getUTCMonth(), 1, 0, 0, 0, 0);
};
exports.getEndOfMonth = function getEndOfMonth(timestamp) {
const d = new Date(timestamp);
const end = Date.UTC(d.getUTCFullYear(), d.getUTCMonth() + 1, 1, 0, 0, 0);
return end - 1;
};

Ubuntu 16.04 + Dell XPS 13 tweaks

Touchscreen

to make touchscreen work:

echo "blacklist usbtouchscreen" | sudo tee -a /etc/modprobe.d/blacklist.conf

Touchpad

#!/bin/bash
appCommand=$1
appName=$2
if [[ `wmctrl -l | grep "$appName"` ]]; then
wmctrl -a "$appName"
else
echo "running $appCommand"
$appCommand
wmctrl -a "$appName"
@finalclass
finalclass / dep-resolve
Created October 20, 2014 23:29
dependency resolving algorithm
/**
* taken from:
* http://www.electricmonk.nl/log/2008/08/07/dependency-resolving-algorithm/
*/
class GraphNode {
public edges:GraphNode[] = [];
constructor(public name:string) {}
public addEdge(c:GraphNode):void {
this.edges.push(c);
<link href="../paper-tabs/paper-tabs.html" rel="import">
<link href="../paper-tabs/paper-tab.html" rel="import">
<polymer-element name="my-element">
<template>
<style>
</style>
@finalclass
finalclass / rename-camel-to-dash.js
Last active March 27, 2023 21:11
recursively renames every file and directory in the script path from camelCase and UpperCamelCase to dash-case
/*jshint node:true*/
'use strict';
/**
* This scripts recursively renames every file and directory in the script path
* from camelCase and UpperCamelCase to dash-case
*
* Do a backup before executing this script
*
* @lecense MIT
@finalclass
finalclass / rework-middleware.js
Last active December 17, 2015 00:29
Rework css framework middleware for connect.
/*jshint node:true*/
'use strict';
var path = require('path'),
url = require('url'),
when = require('when'),
ffs = require('final-fs');
var reworkRecompile = function (cssPath, reworkPath, doRework) {
return ffs.readFile(reworkPath, {encoding: 'utf-8'})
@finalclass
finalclass / join-markdown.js
Created February 14, 2013 22:14
Join .md (markdown) files in directory and save it to build.md file.
#!/usr/local/bin/node
var fs = require('fs');
fs.readdir(__dirname, function (err, files) {
var contents = [],
mdFiles;
mdFiles = files.filter(function (file) {
return file.substr(-3) === '.md' &&
@finalclass
finalclass / gist:3405616
Created August 20, 2012 16:36
Simple boost (v1.48) json reading
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/json_parser.hpp>
#include <boost/filesystem.hpp>
#include <boost/foreach.hpp>
#include <string>
#include <set>
#include <exception>
#include <typeinfo> //for 'typeid' to work