Skip to content

Instantly share code, notes, and snippets.

@xTRiM
xTRiM / dante_proxy.sh
Last active July 20, 2023 10:11 — forked from sarvarrose/dante_proxy.sh
Setup Socks5 Proxy on Ubuntu using Dante
#!/bin/sh
echo_status(){
TEXT=$1
echo "\n $(tput setaf 1)>>>> $(tput setab 7) $TEXT $(tput sgr 0)"
}
SOKSPROXY_PASS=$(openssl rand -base64 12)
echo_status "Updating System and installing dante-server"
@xTRiM
xTRiM / fileless-folders-mtime.sh
Last active September 13, 2020 12:22
Change mtime of fileless directories to that of latest dir under it, recursively. Empty leaf directories, or dirs with only symlinks get the $default_timestamp. Used on git repo clones after git-restore-mtime for proper Docker layer cache key calculation
#! /bin/bash
# Change mtime of fileless directories to that of latest dir under it, recursively
# Empty leaf directories, or dirs with only symlinks get the $default_timestamp
# Used on git repo clones after git-restore-mtime for proper Docker layer cache key calculation
# git-restore-mtime currently doesn't handle dirs which contain other dirs and no files, see
# https://github.com/MestreLion/git-tools/blob/master/git-restore-mtime#L51
# Modified from https://unix.stackexchange.com/a/352334
default_timestamp='1980-01-01 00:00:00'
version: "3"
services:
web:
image: project
restart: always
command: gunicorn conf.wsgi:application -c /opt/project/tools/docker/provision/gunicorn/production.py
expose:
- "8000"
volumes:
- .:/opt/project
def self.tiles_for(lat, lng, search_radius)
adj_lat = (lat + 90).floor
adj_lng = (lng + 180).floor
lat_interval = 110_574 # this is at the poles, its around 111km at the equator so we're using the shorter one - not worth calculating a more accurate value based on lat
# this one is from here: http://en.wikipedia.org/wiki/Longitude
# specifically: PI / 180 cos(theta) * N(theta), and we're using a fixed value
# of N(theta) because its close enough. Basically it is 0 at the poles
# and 68 miles at the equator. We'll allow a minimum of 10km though, which is
# basically at the poles, because I dont want to use a ton of tiles in
BEFORE:
sam@ubuntu discourse % rm -fr tmp/cache
sam@ubuntu discourse % rm -fr public/assets
sam@ubuntu discourse % time RAILS_ENV=production bin/rake assets:precompile
58.55s user 1.79s system 100% cpu 1:00.02 total
AFTER:
--- ext/openssl/ossl.c
+++ ext/openssl/ossl.c
@@ -1048,6 +1048,7 @@ Init_openssl()
*/
/* CRYPTO_malloc_init(); */
/* ENGINE_load_builtin_engines(); */
+ OPENSSL_config(NULL); /* Makes Ruby respect system OpenSSL config */
OpenSSL_add_ssl_algorithms();
OpenSSL_add_all_algorithms();
ERR_load_crypto_strings();
@Grapes([
@Grab('redis.clients:jedis:1.5.1'),
@GrabConfig(systemClassLoader=true)
])
import redis.clients.jedis.*
performTest("unencoded", null) {n, e->
n.toString()
}
class User < ActiveRecord::Base; end;
class Post < ActiveRecord::Base; end;
class Comment < ActiveRecord::Base; end;
class AuthorSerializer < ActiveModel::Serializer
attributes :id, :name :created_at, :updated_at
end
class PostSerializer < ActiveModel::Serializer
attributes :id, :body :created_at, :updated_at
RedisSessionStore.logger = Rails.logger
session_options = {:expire_after => 1.day, :key_prefix => 'sessions'}
MultiSessionStore.stores[:plain] = [RedisSessionStore, session_options.merge(:key => '_session_id')]
MultiSessionStore.stores[:secure] = [RedisSessionStore, session_options.merge(:key => '_secure_session_id', :secure => ['production', 'staging'].include?(Rails.env))]
MultiSessionStore.default_store = :plain
MultiSessionStore.routes = [
['/admin', :secure],
]
@xTRiM
xTRiM / ffmpeg.rb
Created January 17, 2012 14:36 — forked from Flamefork/ffmpeg.rb
ffmpeg & carrierwave
module CarrierWave
module FFMPEG
extend ActiveSupport::Concern
module ClassMethods
def faststart
process :faststart => true
end
def transcode options