Skip to content

Instantly share code, notes, and snippets.

@joseluisq
joseluisq / terminal-git-branch-name.md
Last active April 19, 2024 12:19
Add Git Branch Name to Terminal Prompt (Linux/Mac)

Add Git Branch Name to Terminal Prompt (Linux/Mac)

image

Open ~/.bash_profile in your favorite editor and add the following content to the bottom.

# Git branch in prompt.

parse_git_branch() {
@marcoarment
marcoarment / Sun.swift
Created January 17, 2021 16:43
Get sunrise, sunset, and the sun's position for a given time and location. Based on NOAA Solar Calculator.
// Sun.swift
// Created by Marco Arment on 1/17/21
//
// Solar-math functions are directly translated from the NOAA Solar Calculator:
// https://www.esrl.noaa.gov/gmd/grad/solcalc/
//
// This is free and unencumbered software released into the public domain.
//
// Anyone is free to copy, modify, publish, use, compile, sell, or
// distribute this software, either in source code form or as a compiled
@zachselby
zachselby / unprotect-xlsx.sh
Created August 21, 2020 17:41
Bash Script to Unprotect Sheets in Excel Workbook
#!/bin/bash
#################
# Usage: #
#################
# Create an unprotected copy of XLSX file with suffix "-unprotected.xlsx".
# The following command produces `my-workbook-unprotected.xlsx`
# $ ./unprotect-xlsx.sh my-workbook.xlsx
# This is accomplished by removing from all workbook sheets the `sheetProtection` and `protectedRanges` XML elements.
@amatellanes
amatellanes / pytest.sh
Last active April 19, 2024 12:17
Useful py.test commands.
py.test test_sample.py --collect-only # collects information test suite
py.test test_sample.py -v # outputs verbose messages
py.test -q test_sample.py # omit filename output
python -m pytest -q test_sample.py # calling pytest through python
py.test --markers # show available markers
@sekkr1
sekkr1 / android_gdb.md
Created August 12, 2019 15:27
Attaching GDB to Android apps' native libraries

How to GDB android native libraries

[1] Install NDK from android studio

[2] Push appropriate gdb-server to phone

adb push ~/android-sdk-linux/ndk-bundle/prebuilt/android-<arch>/gdbserver/gdbserver /data/local/tmp
adb shell "chmod 777 /data/local/tmp/gdbserver"
adb shell "ls -l /data/local/tmp/gdbserver"

[4] Forward ports

adb forward tcp:1337 tcp:1337

@myusuf3
myusuf3 / delete_git_submodule.md
Created November 3, 2014 17:36
How effectively delete a git submodule.

To remove a submodule you need to:

  • Delete the relevant section from the .gitmodules file.
  • Stage the .gitmodules changes git add .gitmodules
  • Delete the relevant section from .git/config.
  • Run git rm --cached path_to_submodule (no trailing slash).
  • Run rm -rf .git/modules/path_to_submodule (no trailing slash).
  • Commit git commit -m "Removed submodule "
  • Delete the now untracked submodule files rm -rf path_to_submodule
@iniyan455
iniyan455 / work manager
Last active April 19, 2024 12:15
Work Manager Understanding
Work Manager
WorkManager is an API that makes it easy to schedule deferrable, asynchronous tasks that are expected to run even if the app exits or the device restarts. The WorkManager API is a suitable and recommended replacement for all previous Android background scheduling APIs
Device support from 14 -22 it will work on alarm manager with broadcast to process scheduling and GCM NetworkManager
Device above 23 + all uses JobSchedular
usecases :
Dynamic Feature modules and clean architecture
Backup chat like whatsapp after a hours or 1 in a day
update news in any news app - phone in charge or connect with constraint and executes the task and impl
@frosit
frosit / infectedFiles.md
Created May 5, 2016 22:40
Some commands for finding and clearing infected PHP files

Finding infected files with following bash commands

** Command to list all infected files:

  • grep -lr --include=*.php "eval(base64_decode" /path/to/webroot
  • grep -lr --include=*.php "eval" .
  • grep -lr --include=*.php "base64" .

Command to remove malicious code:

  • grep -lr --include=*.php "eval(base64_decode" /path/to/webroot | xargs sed -i.bak 's/<?php eval(base64_decode[^;]*;/<?php\n/g'
@isti115
isti115 / gamepad-control.py
Created June 19, 2020 20:10
Proof of concept blender addon for controlling the viewport with a gamepad (evdev python module needed, only tested under linux)
bl_info = {
"name" : "Gamepad Control",
"author" : "István Donkó",
"description" : "Control the blender viewport using a gamepad",
"blender" : (2, 80, 1),
# "location" : "View3D",
"category" : "Generic"
}
import bpy
@atimb
atimb / LICENSE.txt
Created December 8, 2011 23:32 — forked from 140bytes/LICENSE.txt
Snake game in 140byt.es
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Attila Incze <http://atimb.me>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE