Skip to content

Instantly share code, notes, and snippets.

Standard naming for variables with files, directories and paths

I suggest to use the following approach in the naming:

  • filename - file name: readme.txt
  • dirname - directory name: mydir
  • filepath - file name, including any path to it: path/to/readme.txt
  • dirpath - directory name, including any path to it: path/to/mydir

As for the words file and dir themselves, I'd recommend not using them for paths at all, because:

@OnkelTem
OnkelTem / index.md
Created June 2, 2022 16:56 — forked from orta/index.md
My Playground Preview

TSNYC Jan 2020


What is TypeScript?

TypeScript extends JavaScript by adding types.

@OnkelTem
OnkelTem / 1.js
Last active July 24, 2019 12:11
[REACT] Map gives its closure, not need to provide more
// Variant 1
const ItemList = ({items, editItem}) => {
render (
<div>
items.map(item => (
<div onClick={(item => () => { editItem(item); })(item)}></div>
)
</div>
);
@OnkelTem
OnkelTem / index.html
Created August 13, 2017 14:54
Freecodecamp.org courses
<h2>Front End Development Certification</h2>
<div>
<div><h3>HTML5 and CSS(5 hours)</h3>
<div><p><a href="https://www.freecodecamp.org/challenges/learn-how-freecodecamp-works">Learn How freeCodeCamp Works</a></p>
<p><a href="https://www.freecodecamp.org/challenges/say-hello-to-html-elements">Say Hello to HTML Elements</a></p>
<p><a href="https://www.freecodecamp.org/challenges/headline-with-the-h2-element">Headline with the h2 Element</a></p>
<p><a href="https://www.freecodecamp.org/challenges/inform-with-the-paragraph-element">Inform with the Paragraph Element</a>
</p>
<p><a href="https://www.freecodecamp.org/challenges/uncomment-html">Uncomment HTML</a></p>
<p><a href="https://www.freecodecamp.org/challenges/comment-out-html">Comment out HTML</a></p>
@OnkelTem
OnkelTem / dropbox
Last active April 28, 2016 08:50
Dropbox startup script for Debian (start-stop-daemon). Place it into /etc/init.d/
#!/bin/sh
### BEGIN INIT INFO
# Provides: dropbox
# Required-Start: $local_fs $remote_fs $network $syslog $named
# Required-Stop: $local_fs $remote_fs $network $syslog $named
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# X-Interactive: false
# Short-Description: dropbox service
### END INIT INFO
#!/bin/bash
[[ -n $args ]] || info "Use params to set number of MBytes to transmit, default 100. e.g.: $current_task=50"
IFS=',' read -a params <<< "$args"
local mb="${params[0]:-100}"
local iperf_port=5001
# Kill possible failed iperf
rcmd root "for pid in \$(pidof iperf); do kill -9 \$pid; done"
<?php
function field_language($entity_type, $entity, $field_name = NULL, $langcode = NULL) {
$display_languages = &drupal_static(__FUNCTION__, array()); // *** This is cache for field languages
...
if (!isset($display_languages[$entity_type][$id][$langcode])) { // *** This is triggered only once, when cache is empty
...
drupal_alter('field_language', $display_language, $context);
->
function entity_translation_field_language_alter(&$display_language, $context) {
BEGIN {
FS="[[:blank:]]*"
OFS = " "
CSYM = csym
PAD = " "
if (CSYM == "") CSYM = "#"
s_starts_len = 0
}
# Reset section when new file is read
$ ip route get 192.168.1.1 from 192.168.1.108
>>
192.168.1.1 from 192.168.1.108 dev eth0
# ip rule add from 192.168.1.108 table 10000
# ip route add throw 192.168.1.108 table 10000
# ip route add default dev wlan0 via 192.168.1.1 table 10000
$ ip route get 192.168.1.1 from 192.168.1.108
$ ip route
default via 192.168.1.1 dev eth0 proto static
169.254.0.0/16 dev wlan0 scope link metric 1000
192.168.1.0/24 dev eth0 proto kernel scope link src 192.168.1.103 metric 1
192.168.1.0/24 dev wlan0 proto kernel scope link src 192.168.1.108 metric 2