Skip to content

Instantly share code, notes, and snippets.

@shnam7
shnam7 / gist:358c1029aba8670ebd5867383afff6ad
Last active December 3, 2023 09:32
Git command examples

Ancestry tree-ish

treeish: branch name, tag, SHA, HEAD, etc.

git show HEAD
git show HEAD^
git show HEAD^^
git show HEAD~1
git show HEAD~2
@shnam7
shnam7 / gist:1ac4cfd302f39b775f80a62c1faf9994
Last active January 14, 2023 10:27
Create svelte-sass-markdown project
# create svelte project using sveltekit
pnpm create svelte@latest my-app
# add markdonw support using svelte-add tool
# https://github.com/svelte-add/mdsvex
pnpx svelte-add@latest mdsvex
# add prism css link from cdn:
# add following contents to /src/routes/+layout.svelte
```svelte
@shnam7
shnam7 / gist:dd382a6a4f1ffda51c1536d0c8d32cdb
Last active September 12, 2022 22:04
WSL2 configuration - mount options with file mode
# /etc/wsl.conf
[automount]
enabled = true
root = /mnt
options = "metadata,umask=022,fmask=011"
mountFsTab = true
[network]
generateHosts = true
@shnam7
shnam7 / gist:3182c0f53b293c27c4e03fda102417cb
Created May 6, 2021 00:58
CMake - detecting target architecture when using vscode
This can be done by adding following to the settings.json
"cmake.configureSettings": {
"TARGET_ARCH": "${buildKitTargetArch}"
},
In CMakeLists.txt, it can be used like this:
#--- check target architecture
if(NOT TARGET_ARCH)
set(TARGET_ARCH "x86_64" CACHE STRING "Choose target architecture, options are: x86, x86_64..." FORCE)
@shnam7
shnam7 / gist:c0c5d0927193556bbce6f2a1a14a66ca
Last active May 6, 2021 00:49
Resolving CMAKE_BUILD_TYPE empty issue in vscode
Add fillowing to settings.json:
"cmake.configureSettings": {
"CMAKE_BUILD_TYPE": "${buildType}"
},
ref: https://github.com/microsoft/vscode-cmake-tools/blob/main/docs/cmake-settings.md
OR,
"cmake.preferredGenerators": [
@shnam7
shnam7 / gist:953d19da155ecb32b4a2923589d6748d
Last active February 9, 2025 16:04
PlatformIO - Changing default projects location in vscode
1. Open PlatformIO terminal: Press <Ctrl>+P and type "platformIO: Net Terminal"
2. In the PlatformIO terminal, execute following command
> platformio settings get projects_dir # check current default location
> platformio settings set projects_dir "New Directory"
3. short command
> pio settings get projects_dir
> pio settings set projects_dir "New Directory"
@shnam7
shnam7 / gist:702bc3b84ea6a4e2c641be09bf4ac857
Created February 29, 2020 05:37
Typescript pick() function
/** pick */
export function pick<T, K extends keyof T>(obj: T, ...keys: K[]): Pick<T, K> {
const ret: any = {};
keys.forEach(key => { ret[key] = obj[key]; });
return ret;
}
@shnam7
shnam7 / gist:27bef6f6f1a180b9a00b4f26db0dcb39
Created July 28, 2019 01:02
Using jQuery plugin in Typescript
//
// Example using jQuery Sidebar
// https://github.com/jillix/jQuery-sidebar
// <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-sidebar/3.3.2/jquery.sidebar.min.js"></script>
//
declare global {
interface JQuery {
sidebar(options?: any): JQuery;
}