Skip to content

Instantly share code, notes, and snippets.

View oprypin's full-sized avatar

Oleh Prypin oprypin

View GitHub Profile
@casivaagustin-zz
casivaagustin-zz / gist:9261586
Created February 27, 2014 23:04
nginx location rule to redirect non existing images to another server
#Rewrites the request, extracting a fragment of the file name and using a remote server.
location @fetchFromRemote {
rewrite ^/path/to/images/(.*)$ http://remoteserver.com/other/path/to/images/$1 redirect;
}
#Will try to see if we have the file in this server, is not will use fetchFromRemote
location ~ ^/path/to/images/.*(png|jpg|jpeg|gif|ico|swf)$ {
try_files $uri @fetchFromRemote;
}
@keplersj
keplersj / logged.rs
Created July 25, 2015 21:00
Gist demonstrating the ability to run Crystal code from Rust.
#[link(name = "logger")]
extern {
fn CrystalLog(text: *const u8);
}
fn log(text: &'static str) {
unsafe{ CrystalLog(text.as_bytes().as_ptr()) };
}
fn main() {
@jc00ke
jc00ke / llvm-update-alternatives
Created November 4, 2014 02:19
LLVM & clang alternatives
#!/usr/bin/env sh
sudo update-alternatives --install \
/usr/bin/llvm-config llvm-config /usr/bin/llvm-config-3.4 200 \
--slave /usr/bin/llvm-ar llvm-ar /usr/bin/llvm-ar-3.4 \
--slave /usr/bin/llvm-as llvm-as /usr/bin/llvm-as-3.4 \
--slave /usr/bin/llvm-bcanalyzer llvm-bcanalyzer /usr/bin/llvm-bcanalyzer-3.4 \
--slave /usr/bin/llvm-cov llvm-cov /usr/bin/llvm-cov-3.4 \
--slave /usr/bin/llvm-diff llvm-diff /usr/bin/llvm-diff-3.4 \
--slave /usr/bin/llvm-dis llvm-dis /usr/bin/llvm-dis-3.4 \
@fonic
fonic / nvidia-sensors.sh
Last active June 24, 2023 12:43
KDE KSysGuard NVIDIA GPU Sensors - see comments below for usage information
#!/usr/bin/env bash
# -------------------------------------------------------------------------
# -
# Created by Fonic (https://github.com/fonic) -
# Date: 12/29/19 - 02/12/20 -
# -
# Created for and tested on single-GPU system equipped with NVIDIA -
# GeForce RTX 2060 SUPER. For other systems, modifications might be -
# required. -
@mattcarp
mattcarp / unicode_fuzz.py
Created July 24, 2012 22:09
Generates a random length string of non-control Unicode characters
#!/usr/bin/python
import random
import unicodedata
def unicode_fuzz(lower_limit=0, upper_limit=60):
unicode_glyphs = ''.join(
unichr(char)
for char in xrange(65533)
# use the unicode categories that don't include control codes
@jwo
jwo / query.graphql
Last active May 31, 2021 20:53
GraphQL example: current user's 100 most current public repos
{
viewer {
repositories(privacy: PUBLIC, first: 3, orderBy: {field: PUSHED_AT, direction: DESC}) {
nodes {
nameWithOwner
url
}
}
}
}
@jhass
jhass / server.cr
Created July 22, 2016 12:05
Simple debug HTTP server in Crystal
require "option_parser"
require "http/server"
require "json"
class Settings
property port = 3000
property host = "127.0.0.1"
property? show_headers = false
property? show_raw_json = false
end
@tmatilai
tmatilai / Vagrantfile
Last active January 1, 2021 19:49
My global Vagrant configuration (~/.vagrant.d/Vagrantfile)
# URI of the local (caching) HTTP proxy
LOCAL_HTTP_PROXY = 'http://192.168.33.200:8123'
# Configures vagrant-cachier and vagrant-proxyconf.
# Should be called only on "local machine" providers.
def configure_caching(config)
if Vagrant.has_plugin?('vagrant-cachier')
config.cache.enable_nfs = true
config.cache.enable :gem
config.cache.enable :npm
@ivanistheone
ivanistheone / samizdat-shell-help.bash
Last active December 17, 2020 22:23 — forked from kovetskiy/samizdat-shell-help.bash
help text for bas script based on ### comment + awk command
#!/bin/bash
###
### my-script — does one thing well
###
### Usage:
### my-script <input> <output>
###
### Options:
### <input> Input file to read.
### <output> Output file to write. Use '-' for stdout.
data = [{"Brian", 42}, {"Alan", 30}, {"Brian", 32}]
# unstable
data.sort_by &.[0] # => [{"Brian", 42}, {"Alan", 30}, {"Brian", 32}]
# stable
data.map_with_index { |d,i| {d,i} }.sort_by { |di| {di[0][0], di[1]} }.map { |di| di[0] } # => [{"Alan", 30}, {"Brian", 42}, {"Brian", 32}]