Skip to content

Instantly share code, notes, and snippets.

View cantecim's full-sized avatar
✌️
work wonders

Can Tecim cantecim

✌️
work wonders
View GitHub Profile

Recursively copy a directory (using cp, tar or rsync)

Original Source: http://snipplr.com/view/26670/

Reformatted for improved readability and personal reference.

How does one make a recursive, identical copy of /source/ into /target/?

I suppose you want to do that for archiving or duplicating something and want to preserve "everything". That includes permissions, ownership, filetypes, timestamps etc.

@cantecim
cantecim / random.md
Created October 9, 2023 15:12 — forked from joepie91/random.md
Secure random values (in Node.js)

Not all random values are created equal - for security-related code, you need a specific kind of random value.

A summary of this article, if you don't want to read the entire thing:

  • Don't use Math.random(). There are extremely few cases where Math.random() is the right answer. Don't use it, unless you've read this entire article, and determined that it's necessary for your case.
  • Don't use crypto.getRandomBytes directly. While it's a CSPRNG, it's easy to bias the result when 'transforming' it, such that the output becomes more predictable.
  • If you want to generate random tokens or API keys: Use uuid, specifically the uuid.v4() method. Avoid node-uuid - it's not the same package, and doesn't produce reliably secure random values.
  • If you want to generate random numbers in a range: Use random-number-csprng.

You should seriously consider reading the entire article, though - it's

@cantecim
cantecim / pycompat.py
Created November 17, 2017 13:19
odoo v11 translate patch for python2x
# -*- coding: utf-8 -*-
# to remove if we decide to add a dependency on six or future
# very strongly inspired by https://github.com/pallets/werkzeug/blob/master/werkzeug/_compat.py
#pylint: disable=deprecated-module
import csv
import codecs
import collections
import io
import sys
@cantecim
cantecim / foxitcl-mobilePolyForm.js
Last active January 16, 2016 16:28 — forked from premiumFrye/pf-mobilePolyForm.js
A directive for making Android behave a bit more like iOS when filling out forms using the ionic framework. Directive will automatically advance cursor to next field when user taps return, and if the next field is a select input, automatically pop open options. Additionally, this directive solves an issue where angularjs won't update ng-model an…
angular.module('foxitcl-mobilePolyform', [])
.directive('mobileFormPolyfill', function($timeout, $parse) {
return {
compile: function(tElement, tAttrs) {
tAttrs.inputs = [];
tAttrs.keydownFns = [];
var formElements = tElement[0].elements,
k = -1;
Object.keys(formElements).forEach(function(elm) {
@cantecim
cantecim / node-and-npm-in-30-seconds.sh
Created July 30, 2015 02:09 — forked from isaacs/node-and-npm-in-30-seconds.sh
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.com/install.sh | sh
@cantecim
cantecim / data.sql
Last active August 29, 2015 14:18
PostgreSQL All ISO Languages
This file has been truncated, but you can view the full file.
INSERT INTO "Language" ("SK_Language", "ISO639-3Code", "ISO639-2BCode", "ISO639-2TCode", "ISO639-1Code", "LanguageName", "Scope", "Type", "MacroLanguageISO639-3Code", "MacrolanguageName", "IsChild", "SK_Language", "ISO639-3Code", "ISO639-2BCode", "ISO639-2TCode", "ISO639-1Code", "LanguageName", "Scope", "Type", "MacroLanguageISO639-3Code", "MacrolanguageName", "IsChild") VALUES
(17840, 'ayr', '', '', '', 'Central Aymara', 'Individual', 'Living', 'aym', 'Aymara', true, 17840, 'ayr', '', '', '', 'Central Aymara', 'Individual', 'Living', 'aym', 'Aymara', true),
(17841, 'ays', '', '', '', 'Sorsogon Ayta', 'Individual', 'Living', '', '', false, 17841, 'ays', '', '', '', 'Sorsogon Ayta', 'Individual', 'Living', '', '', false),
(17842, 'ayt', '', '', '', 'Magbukun Ayta', 'Individual', 'Living', '', '', false, 17842, 'ayt', '', '', '', 'Magbukun Ayta', 'Individual', 'Living', '', '', false),
(17843, 'ayu', '', '', '', 'Ayu', 'Individual', 'Living', '', '', false, 17843, 'ayu', '', '', '', 'Ayu', 'Individual',
@cantecim
cantecim / plpgsql_iso639-1_languages.sql
Last active January 20, 2023 12:40
PostgreSQL ISO639-1 Language Codes SQL
CREATE TABLE public.languages (
id serial NOT NULL,
code varchar(2) NOT NULL,
"language" varchar(30),
/* Keys */
CONSTRAINT languages_pkey
PRIMARY KEY (id)
) WITH (
OIDS = FALSE
);