Skip to content

Instantly share code, notes, and snippets.

@elicore
elicore / redisbasicpersistence.py
Created March 18, 2019 04:57
Redis Persistence / Conversations
from collections import defaultdict
from telegram.ext import BasePersistence
from walrus import Walrus, Hash
class DefaultDataDict(defaultdict):
def __init__(self, redis: Walrus, prefix: str = None):
self.redis = redis
self.prefix = prefix or 'default_data_dict'

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@elicore
elicore / IntelIJTrialReset.bat
Created March 18, 2019 04:58
How to Reset InteIIiJ IDEA Evaluation Key in Windows
cd "C:%HOMEPATH%\.IntelliJIdea*\config"
rmdir "eval" /s /q
del "options\other.xml"
reg delete "HKEY_CURRENT_USER\Software\JavaSoft\Prefs\jetbrains\idea" /f
:: This will work for idea 2018.3 and later
::
:: It is Highly Advised to Purchase the JetBrain Softwares
:: This is only for the case You just want to Extend the
:: Trial Period and Evaluate the IDE for some more Time
@elicore
elicore / tmux.md
Created March 18, 2019 04:58 — forked from andreyvit/tmux.md
tmux cheatsheet

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a

@elicore
elicore / postgres-cheatsheet.md
Created March 18, 2019 04:59 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)

Postgres Cheatsheet

This is a collection of the most common commands I run while administering Postgres databases. The variables shown between the open and closed tags, "<" and ">", should be replaced with a name you choose. Postgres has multiple shortcut functions, starting with a forward slash, "". Any SQL command that is not a shortcut, must end with a semicolon, ";". You can use the keyboard UP and DOWN keys to scroll the history of previous commands you've run.

Setup

installation, Ubuntu

http://www.postgresql.org/download/linux/ubuntu/ https://help.ubuntu.com/community/PostgreSQL

#verify this is the console and not the ISE
Import-Module Get-ChildItemColor
Set-Alias l Get-ChildItemColor -option AllScope
Set-Alias ls Get-ChildItemColorFormatWide -option AllScope
function ll{
return l | select Mode, @{Name="LastWriteTime"; Expression={$_.LastWriteTime.ToString("yyyy-MM-dd HH:mm")}}, @{Name='Size'; Expression={if ($_.Attributes -ne 'Directory') {$_.Length} else {''}}}, Name
}
Set-Alias dir Get-ChildItemColor -option AllScope -Force
@elicore
elicore / .go-my-posh-default.json
Last active January 15, 2021 15:36
Microsoft.PowerShell_profile.ps1
{
"final_space": true,
"console_title": false,
"blocks": [
{
"type": "prompt",
"alignment": "left",
"horizontal_offset": 0,
"vertical_offset": 0,
"segments": [
// Create a kaltura session (ks) using an app token in nodejs
// First install the Kaltura client library: npm install kaltura-client
// Details from your Kaltura account: partner id (pid), apptoken id, apptoken hash
const kaltura = require('kaltura-client');
const client = new kaltura.Client(new kaltura.Configuration());
let widgetId = "_YOUR-PID";
let expiry = 86400;
var crypto = require('crypto');
@elicore
elicore / spotlight.ps1
Created June 17, 2022 12:58
Saving Microsoft Spotlight (lock screen photos)
$save_folder = "C:\Users\my_username\Pictures\Spotlight"
$saved_names = dir $save_folder | foreach Name
$spotlight_folder = $env:LOCALAPPDATA + "\Packages\Microsoft.Windows.ContentDeliveryManager_cw5n1h2txyewy\LocalState\Assets"
$spotlight_files = (dir $spotlight_folder)
foreach ($file in $spotlight_files) {
$saved_name = (Split-Path $file -Leaf) + ".jpg"
if ($saved_names -contains $saved_name) {
continue