Skip to content

Instantly share code, notes, and snippets.

@cristian-aldea
cristian-aldea / slick-terminal.md
Last active May 16, 2024 07:48
Ubuntu + Zsh + Oh My Zsh + Powerlevel10k = Sliiiiiiiiiiiiick

Based on: https://gist.github.com/kevin-smets/8568070

This gist outlines the steps needed to setup zsh, ohmyzsh and the powerlevel10k theme, available for anyone to follow.

  1. Setup required dependencies

    # update packages
    sudo apt update
    
# Hello, and welcome to makefile basics.
#
# You will learn why `make` is so great, and why, despite its "weird" syntax,
# it is actually a highly expressive, efficient, and powerful way to build
# programs.
#
# Once you're done here, go to
# http://www.gnu.org/software/make/manual/make.html
# to learn SOOOO much more.
@iamcalledrob
iamcalledrob / CaptureComposable.kt
Last active May 16, 2024 07:48
Android headless composable capture
import android.app.Presentation
import android.content.Context
import android.graphics.Bitmap
import android.graphics.Picture
import android.graphics.SurfaceTexture
import android.hardware.display.DisplayManager
import android.view.Display
import android.view.Surface
import android.view.ViewGroup
import androidx.compose.foundation.layout.Box
@derbydefi
derbydefi / elm.py
Last active May 16, 2024 07:47
Extreme Learning Machine Python Implementation
import time
import torch
import torchvision
import torchvision.transforms as transforms
class ELM(torch.nn.Module):
def __init__(self, input_size, hidden_size, output_size):
super(ELM, self).__init__()
self.hidden_size = hidden_size
self.input_weights = torch.nn.Parameter(torch.randn(input_size, hidden_size) * 0.1, requires_grad=False)
@jahe
jahe / spring-boot-cheatsheet.java
Last active May 16, 2024 07:44
Spring Boot Cheatsheet
// Enable component-scanning and auto-configuration with @SpringBootApplication Annotation
// It combines @Configuration + @ComponentScan + @EnableAutoConfiguration
@SpringBootApplication
public class FooApplication {
public static void main(String[] args) {
// Bootstrap the application
SpringApplication.run(FooApplication.class, args);
}
}
@Webreaper
Webreaper / docker-compose.yml
Last active May 16, 2024 07:40
Sample Docker-compose file which shows how to set up Sonarr, Radarr, Prowlarr, Lidarr, QBittorrent and a VPN container so that all all traffic from the containers is routed through the VPN. Also includes Plex and get_iplayer containers, which are not routed through the VPN.
# Docker compose to set up containers for all services you need:
# VPN
# Sonarr, Radarr, Lidarr, Qbittorrent
# Non-VPN
# Plex, get_iplayer
# Before running docker-compose, you should pre-create all of the following folders.
# Folders for Docker State:
# /volume1/dockerdata. - root where this docker-compose.yml should live
# /volume1/dockerdata/plex - Plex config and DB
# /volume1/dockerdata/sonarr - Sonarr config and DB
@tjsudarsan
tjsudarsan / Change CRLF to LF to all Files.md
Last active May 16, 2024 07:40
Change End of Line Sequence from CRLF to LF to all files in the project for supporting ESLint

Converting the End of Line Sequence from CRLF to LF in any of your project files

Execute the following commands in your root of your project folder

NOTE: Do not do the following steps without commiting your data. As it clears all the git cache and it will clear all your changes in your project.

  1. First disable the autoCRLF in the git config by running the following command in your terminal git config core.autocrlf false

  2. Then remove the cached files in the git. Run the following command:

@JamesYang76
JamesYang76 / Time Zone.md
Last active May 16, 2024 07:46
Time Zone for rails

Time zones

There are trhee diffrent time zones in rails

  • System - The server time zone
  • Application - Rails application use own time zone
  • Database - Default is UTC, but do not change it

Cautions

  • config.time_zone should be set when an app dose not support multiple time zones
  • Do not use Date/Time API using system time zone
  • Date could be incorrect by being converted from datetime or time to date
@stefansundin
stefansundin / make-chrome-app.sh
Last active May 16, 2024 07:39
Create Chrome apps in Mac OS.
#!/bin/sh
# wget https://gist.githubusercontent.com/stefansundin/c89fd15bae5a58831790/raw/make-chrome-app.sh
# chmod +x make-chrome-app.sh
# ./make-chrome-app.sh
echo "Note that the app will run with a separate data dir and thus not have your regular extensions and settings."
echo
echo "What should the app be called?"
read name
echo
@ctlllll
ctlllll / longest_chinese_tokens_gpt4o.py
Created May 13, 2024 19:53
Longest Chinese tokens in gpt4o
import tiktoken
import langdetect
T = tiktoken.get_encoding("o200k_base")
length_dict = {}
for i in range(T.n_vocab):
try:
length_dict[i] = len(T.decode([i]))
except: