Skip to content

Instantly share code, notes, and snippets.

@colxi
colxi / xrandr.txt
Created September 27, 2017 22:16
xrandr - force resolution in linux
Most netbooks including the Acer Aspire One (zg5) have a native screen resolution of 1024x600 which can be a pain with some applications that require 1024x768 minimum .. some setting dialogs also seem to be larger than the screen allows.
Well you CAN get Peppermint 4 (or any distro based on >= Ubuntu 12.10) to give you 1024x768
This should work for Peppermint 4 .. and possibly for a FULLY updated Peppermint 3 (I can't currently test it in Peppermint 3 .. Ubuntu 12.04 based distros *used* to need a patched version of xorg but I *think* the patch was added in ubuntuupdates)
Run this in a terminal:
Code: [Select]
xrandr --output LVDS1 --panning "1024x768" --scale "1x1.28"
/**
* The individual bits of 'x' are named b7, b6, b5, b4, b3, b3, b2, b1 and b0.
* The bit b7 is the sign bit (the most significant bit), and b0 is the least significant.
* x = byte(s) to operate with
* n = number of bit to manipulate
* v = new value to the bit
*/
/**
* The idea here is that an integer is odd if and only if the least significant bit b0 is 1.
@colxi
colxi / dynamic-module-import-polyfill.js
Last active May 25, 2018 21:36
Dynamic import function for ES modules polyfill
// Addapted from :
// https://github.com/tc39/proposal-dynamic-import
function importModule(url) {
return new Promise((resolve, reject) => {
const script = document.createElement("script");
const loaderId = "__tempModuleLoadingVariable" + Math.random().toString(32).substring(2);
window[loaderId] = function( m ){
resolve( m );
@colxi
colxi / in-viewport.js
Created August 2, 2018 02:54
detect if HTML element is displayed in browser viewport
function isElementInViewport (el) {
var rect = el.getBoundingClientRect();
return (
rect.top >= 0 &&
rect.left >= 0 &&
rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) && /*or $(window).height() */
rect.right <= (window.innerWidth || document.documentElement.clientWidth) /*or $(window).width() */
);
@colxi
colxi / ast-keypaths.js
Created September 3, 2018 19:48
Extract keypaths from expression AST (abstract syntax tree)
// works with AST generated by esprima or jsep
const Parser = {
// 'global' for Node, or any other value for custom scenaros
outerscope : 'window',
getObservablePaths : function(expression) {
console.log('Parser.getPaths',expression);
var ast = esprima.parse(expression);
if (ast) {
@colxi
colxi / README.md
Last active August 1, 2022 08:42
SCRIPT-8
Connect to MongoDb shell
---------------------------
mongo "<server-address>/<database>" --username <username> --password <password>
MongoDb shell commands
---------------------------
Show selected db
> db
@colxi
colxi / getBase64Image.js
Created March 9, 2019 22:49
getBase64Image() : Get the Base64 representation of an image from its url
// get an image blob from url using fetch
let getImageBlob = function(url){
return new Promise( async resolve=>{
let resposne = await fetch( url );
let blob = resposne.blob();
resolve( blob );
});
};
// convert a blob to base64
@colxi
colxi / fps.js
Created April 12, 2019 03:58
Calculate FPS average with customizable fps sample length
const fps = {
sampleSize : 60,
value : 0,
_sample_ : [],
_index_ : 0,
_lastTick_: false,
tick : function(){
// if is first tick, just set tick timestamp and return
if( !this._lastTick_ ){
@colxi
colxi / php-console.php
Created April 27, 2019 04:59
php-console.php
<?php
/*
Project Name: PHPConsole
Usage: Upload this file to FTP space, and run it from browser.
Description: PHPConsole is a simple and compact browser-based AJAX PHP console, that
allows direct acces to the PHP erver-side interpreter, recieving via AJAX all your
code output.
WARNING! ENSURE YOU CHANGE THE DEFAULT PASSWORD BEFORE UPLOADING!
Version: 1.5
Author: c0lx1