Skip to content

Instantly share code, notes, and snippets.

View cedricvidal's full-sized avatar

Cedric Vidal cedricvidal

View GitHub Profile
@cedricvidal
cedricvidal / Fix Apple Photos timestamps.scpt
Last active February 13, 2023 17:28
Fix Apple Photos timestamps Applescript script
use AppleScript version "2.4"
use framework "Foundation"
use scripting additions
# This script fixes timestamps of photos currently selected in OSX Photos application.
# It does so by reading a CSV file containing mappings from file names to timestamps.
# The user is requested to select the CSV file when running this script.
# Author: Cedric Vidal (https://vidal.biz)
@cedricvidal
cedricvidal / git-move-subdir-cross-repo.sh
Last active October 4, 2019 05:13 — forked from trongthanh/gist:2779392
How to move a folder from one repo to another and keep its commit history
# source: http://st-on-it.blogspot.com/2010/01/how-to-move-folders-between-git.html
# First of all you need to have a clean clone of the source repository so we didn't screw the things up.
git clone git://server.com/my-repo1.git
# After that you need to do some preparations on the source repository, nuking all the entries except the folder you need to move. Use the following command
git filter-branch --subdirectory-filter your_dir -- -- all
# This will nuke all the other entries and their history, creating a clean git repository that contains only data and history from the directory you need. If you need to move several folders, you have to collect them in a single directory using the git mv command.
@cedricvidal
cedricvidal / gist:8e1dce995d99ddd6812df7827dfc710d
Created March 11, 2019 15:29
Extract JIRA Ticker from GIT branch name regexp
^(?'remote'[a-zA-Z]+)\/(?'sub'[a-zA-Z]+\/)?(?'jira_project'[A-Z]+)-(?'jira_ticket'[0-9]+).*$
@cedricvidal
cedricvidal / .envrc
Created February 23, 2019 10:53
Node sample direnv
# Add node_modules/.bin to PATH
layout node
set -e
# Use specific node version using nvm
NODE_VERSION_PREFIX=v
NODE_VERSIONS=~/.nvm/versions/node
use node
@cedricvidal
cedricvidal / java-collections-complexity.md
Last active July 30, 2022 15:43 — forked from psayre23/gist:c30a821239f4818b0709
Runtime Complexity of Java Collections

Below are the Big O performance of common functions of different Java Collections.

List Add Remove Get Contains Next Data Structure
ArrayList O(1) O(n) O(1) O(n) O(1) Array
LinkedList O(1) O(1) O(n) O(n) O(1) Linked List
CopyOnWriteArrayList O(n) O(n) O(1) O(n) O(1) Array
@cedricvidal
cedricvidal / git_log_csv.sh
Created January 11, 2019 17:05
Git log CSV
(SEP=",";\
echo "Hash${SEP}AuthorName${SEP}AuthorEmail${SEP}CommiterName${SEP}CommiterEmail${SEP}AuthorDate${SEP}Subject"; \
git log --pretty=format:"%h${SEP}%an${SEP}%ae${SEP}%cn${SEP}%ce${SEP}%ad${SEP}%s" --all --date=short\
)
@cedricvidal
cedricvidal / example.sql
Last active November 15, 2018 09:59
Oracle SQL Developer - Export query to CSV
SPOOL "/tmp/export.csv"
select /*csv*/ *
from ( select /*+ FIRST_ROWS(n) */
a.*, ROWNUM rnum
from ( SELECT c1, TIMESTAMP FROM mytable ORDER BY timestamp ) a
where ROWNUM <=
110 )
where rnum >= 100;
/* Source https://stackoverflow.com/questions/4168398/how-to-export-query-result-to-csv-in-oracle-sql-developer */
@cedricvidal
cedricvidal / README.md
Created November 15, 2018 09:57
Optimized Oracle pagination

Where :

  • FIRST_ROWS(N) tells the optimizer, "Hey, I'm interested in getting the first rows, and I'll get N of them as fast as possible."
  • :MAX_ROW_TO_FETCH is set to the last row of the result set to fetch—if you wanted rows 50 to 60 of the result set, you would set this to 60.
  • :MIN_ROW_TO_FETCH is set to the first row of the result set to fetch, so to get rows 50 to 60, you would set this to 50.

Source https://blogs.oracle.com/oraclemagazine/on-rownum-and-limiting-results

@cedricvidal
cedricvidal / s.py
Created October 22, 2018 17:34
Python 2 non blocking asyncore port forwarding TCP proxy
#!/usr/bin/env python
#
# s.py - a simple port forwarder using asyncore
#
# by Yusuke Shinyama, *public domain*
# http://www.unixuser.org/~euske/python/s.py
#
import sys, socket, asyncore
@cedricvidal
cedricvidal / install_docker.sh
Created October 28, 2017 10:59
Howto install docker on OSX latest known working way
brew cask install docker