Skip to content

Instantly share code, notes, and snippets.

@1kko
1kko / repo.sh
Last active May 14, 2024 09:58
Bash - performs search of specific directory up to 2 depth and change directory into it
# This script performs search of specific directory up to 2 depth and change directory into it.
# This is helpful for cases like having many repositories and need to cd into it.
# Install
# 1. Install fzf(https://github.com/junegunn/fzf#related-projects). eg: sudo apt install fzf (
# 2. Copy this source and paste into paste into your: nano ~/.bashrc
# 3. Edit the srchDir variable for your environment
# 4. Save and start new session of terminal
# Usage
[ req ]
default_bits = 2048
default_keyfile = server-key.pem
distinguished_name = subject
req_extensions = req_ext
x509_extensions = x509_ext
string_mask = utf8only
[ subject ]
@ih2502mk
ih2502mk / list.md
Last active May 14, 2024 09:53
Quantopian Lectures Saved
@hamzaakhtar953
hamzaakhtar953 / CELERYCONFIG.md
Last active May 14, 2024 09:53
Configuring Celery + Redis + Supervisor with Django

Configuring Celery + Redis + Supervisor with Django

Install Celery

$ pip install celery
$ pip install redis

Install Celery Broker

@Laurian
Laurian / subtitles.py
Created January 20, 2016 20:18
movie.py subtitles example
from moviepy.editor import *
from moviepy.video.tools.subtitles import SubtitlesClip
generator = lambda txt: TextClip(txt, font='Arial', fontsize=16, color='white')
subtitles = SubtitlesClip("somet.srt", generator)
video = VideoFileClip("some.mp4")
result = CompositeVideoClip([video, subtitles.set_pos(('center','bottom'))])
result.write_videofile("out.mp4", fps=video.fps, temp_audiofile="temp-audio.m4a", remove_temp=True, codec="libx264", audio_codec="aac")
@chrisnolet
chrisnolet / .zshrc
Last active May 14, 2024 09:51
Color-coded git branch for zsh prompt
autoload -Uz compinit && compinit
autoload -Uz add-zsh-hook
autoload -Uz vcs_info
add-zsh-hook precmd vcs_info
zstyle ':vcs_info:*' enable git
zstyle ':vcs_info:*' formats " %F{cyan}%c%u(%b)%f"
zstyle ':vcs_info:*' actionformats " %F{cyan}%c%u(%b)%f %a"
zstyle ':vcs_info:*' stagedstr "%F{green}"
@hoangsonww
hoangsonww / batch_rename_files.py
Created March 14, 2024 07:39
Batch File Renamer
import os
def batch_rename_files(directory, prefix):
"""
Renames all files in the given directory with the given prefix followed by a sequential number,
keeping their original file extensions intact. This can be useful for organizing a large number
of files in a systematic way, such as photos from an event, downloaded files, etc.
Parameters:
- directory: The path to the directory containing the files to be renamed.
@hoangsonww
hoangsonww / text_summarizer.py
Created March 14, 2024 07:42
Text Summarization with AI
from transformers import pipeline, T5Tokenizer
def summarize_text(text, max_length=130, min_length=30, model_name='t5-small'):
"""
Summarizes long texts using a pre-trained model from Hugging Face's Transformers.
This enhanced version includes functionality to handle large texts by breaking them
into manageable chunks, addressing the token limit constraint of the model.
Parameters:
- text: The text to be summarized.
@ulrikdamm
ulrikdamm / EditPrefab.cs
Last active May 14, 2024 09:51
Unity editor script for better editing of prefabs. Put in Assets/Editor.
using UnityEngine;
using UnityEditor;
using UnityEditor.SceneManagement;
// Adds a "Edit Prefab" option in the Assets menu (or right clicking an asset in the project browser).
// This opens an empty scene with your prefab where you can edit it.
// Put this script in your project as Assets/Editor/EditPrefab.cs
public class EditPrefab {
static Object getPrefab(Object selection) {
@hoangsonww
hoangsonww / Blockchain.py
Created April 8, 2024 04:05
A basic blockchain structure in Python with proof-of-work consensus, transaction handling, and wallet functionalities.
import hashlib
import json
from time import time
import binascii
from collections import OrderedDict
from uuid import uuid4
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.asymmetric import ec
from cryptography.hazmat.primitives import serialization
from cryptography.exceptions import InvalidSignature