Skip to content

Instantly share code, notes, and snippets.

View cloudhx's full-sized avatar
♨️

Cloud Han Xiao cloudhx

♨️
  • Nordsense
  • Copenhagen, Denmark
View GitHub Profile
@ray007
ray007 / jsUrlPoly.js
Last active December 19, 2023 04:22
URL polyfill for nativescript
// polyfill URL since that seems to not be done for nativescript
import { path } from "@nativescript/core";
import 'url-search-params-polyfill';
if (!global.URL) {
class URL {
constructor(sUrl, base) {
@shiv19
shiv19 / getNavBarHeight.js
Created January 6, 2019 21:56
Get Android Navigation bar height NativeScript
function getNavBarHeight() {
const app = require("application");
if (app.android) {
let navBarHeight = 0;
let windowManager = app.android.context
.getSystemService(android.content.Context.WINDOW_SERVICE);
let d = windowManager.getDefaultDisplay();
let realDisplayMetrics = new android.util.DisplayMetrics();
d.getRealMetrics(realDisplayMetrics);
@serg0x
serg0x / material-design-shadows.css
Last active July 7, 2023 13:33
Google material design elevation system shadows as css. Based on https://material.io/design/environment/elevation.html#default-elevations Exported with Sketchapp from the Google material design theme editor plugin "Baseline" theme.
/* Shadow 0dp */
box-shadow: none;
/* Shadow 1dp */
box-shadow: 0 1px 1px 0 rgba(0,0,0,0.14), 0 2px 1px -1px rgba(0,0,0,0.12), 0 1px 3px 0 rgba(0,0,0,0.20);
/* Shadow 2dp */
box-shadow: 0 2px 2px 0 rgba(0,0,0,0.14), 0 3px 1px -2px rgba(0,0,0,0.12), 0 1px 5px 0 rgba(0,0,0,0.20);
/* Shadow 3dp */
@rudolfratusinski
rudolfratusinski / parallels_tools_ubuntu_new_kernel_fix.md
Last active November 23, 2022 20:01
Parallels Tools fix for Ubuntu 18.04 and other Linux distributions with Kernel version >= 4.15

Preparation

  • In open Ubuntu 18.04 machine click Parallels Actions -> "Install Parallels Tools"

  • A "Parallels Tools" CD will popup on your Ubuntu desktop.

  • Open it by double mouse click, copy all the content to a new, empty directory on a desktop, name it for e.g. "parallels_fixed"

  • Open terminal, change directory to parallels_fixed (cd ~/Desktop/parallels_fixed)

  • Make command line installer executable (chmod +x install)

  • Change directory to "installer" (cd installer)

  • Make few other scripts executable: chmod +x installer.* *.sh prl_*

@leonardokl
leonardokl / npm-version-cheatsheet.md
Last active March 19, 2024 08:09
npm version cheatsheet

NPM VERSION

Bump a package version

major (Breaking Change)

# version 1.0.0
$ npm version major # 2.0.0
$ npm version premajor # 2.0.0-0
@danishabdullah
danishabdullah / Postgres kill all idle in transaction.md
Last active February 27, 2024 19:55
Postgres kill all idle in transaction

given a database named db:

SELECT pg_terminate_backend(pid) 
FROM pg_stat_activity 
WHERE datname='db'
  AND state = 'idle in transaction'
@mkhatib
mkhatib / geo.js
Created May 24, 2013 02:55
A Javascript utility function to generate number of random Geolocations around a center location and in a defined radius.
/**
* Generates number of random geolocation points given a center and a radius.
* @param {Object} center A JS object with lat and lng attributes.
* @param {number} radius Radius in meters.
* @param {number} count Number of points to generate.
* @return {array} Array of Objects with lat and lng attributes.
*/
function generateRandomPoints(center, radius, count) {
var points = [];
for (var i=0; i<count; i++) {