This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import threading | |
class ThreadSafeCounter: | |
def __init__(self, counter=0, max_counter=0): | |
self.lock = threading.Lock() | |
self.counter = counter | |
self.max_counter = max_counter |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
dir="/Users/$USER/images" | |
find $dir -type f -name '*.png' -print0 | while IFS= read -r -d '' file; do | |
convert "$file" "${file%.*}.jpg" | |
rm -f $file | |
echo "$file converted" | |
done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT MAX(id) FROM "Content"; | |
SELECT nextval('"Content_id_seq"'::text); | |
BEGIN; | |
-- protect against concurrent inserts while you update the counter | |
LOCK TABLE "Content" IN EXCLUSIVE MODE; | |
-- Update the sequence | |
SELECT setval('"Content_id_seq"', COALESCE((SELECT MAX(id)+1 FROM "Content"), 1), false); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 🚀 Fiber is an Express inspired web framework written in Go with 💖 | |
// 📌 API Documentation: https://fiber.wiki | |
// 📝 Github Repository: https://github.com/gofiber/fiber | |
package main | |
import ( | |
"context" | |
"log" | |
"time" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git update-index --add --chmod=+x filename.sh | |
git commit -m 'filename permission error fixed.' | |
git push |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
```bash | |
$ brew install tcl-tk | |
$ pyenv uninstall {used_version} | |
$ env \ | |
PATH="$(brew --prefix tcl-tk)/bin:$PATH" \ | |
LDFLAGS="-L$(brew --prefix tcl-tk)/lib" \ | |
CPPFLAGS="-I$(brew --prefix tcl-tk)/include" \ | |
PKG_CONFIG_PATH="$(brew --prefix tcl-tk)/lib/pkgconfig" \ | |
CFLAGS="-I$(brew --prefix tcl-tk)/include" \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export ZSH="/Users/$USER/.oh-my-zsh" | |
# Set name of the theme to load --- if set to "random", it will | |
# load a random theme each time oh-my-zsh is loaded, in which case, | |
# to know which specific one was loaded, run: echo $RANDOM_THEME | |
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes | |
ZSH_THEME="random" | |
# Set list of themes to pick from when loading at random | |
# Setting this variable when ZSH_THEME=random will cause zsh to load |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM openjdk:8-jdk-alpine | |
##ENV GRADLE_VERSION 6.2.2 | |
##ENV GRADLE_HOME /opt/gradle | |
##ENV PATH ${PATH}:${GRADLE_HOME}/bin | |
RUN apk update \ | |
&& apk add --no-cache curl bash | |
# Install gradle |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
filename = 'filename.csv' | |
chunksize = 10 ** 6 | |
chunk_list = [] | |
for chunk in pd.read_csv(filename, chunksize=chunksize, error_bad_lines=False): | |
chunk_list.append(chunk) | |
df = pd.concat(chunk_list) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def highlight(row): | |
if row > 60: | |
return 'background-color: green' | |
else: | |
return 'background-color: none;' | |
df = df.style.applymap(highlight, subset=['Term', 'Count']) |
NewerOlder