Skip to content

Instantly share code, notes, and snippets.

View dejurin's full-sized avatar
💭
;-)

YURII D. dejurin

💭
;-)
  • Si-ɑR
  • București, România 🇷🇴
  • 20:21 (UTC +03:00)
View GitHub Profile
@behringer24
behringer24 / nginx.conf
Created January 25, 2012 11:23
nginx configuration snippet for dynamic image manipulation using HttpImageFilterModule
/*
* nginx configuration snippet for dynamic image manipulation using HttpImageFilterModule
*
* URL example: http://www.yourserver.com/imgresize/250-100-0/demo.jpg
* Parameters are width-height-rotation
* You need to compile nginx with --with-http_image_filter_module
* More information at http://wiki.nginx.org/HttpImageFilterModule
*/
location ~/imgresize/(?P<width>[0-9]+)-(?P<height>[0-9]+)-(?P<rotate>[0-9]+)/(?P<filename>.+)$ {
rewrite /imgresize/[0-9]+-[0-9]+-[0-9]+/(.+)$ /images/$1 break;
@jeffreybarke
jeffreybarke / ci-encryption-key-generator.php
Created April 9, 2013 17:21
This is the code I use (minus Google Analytics) for the CodeIgniter encryption key generator located at http://jeffreybarke.net/tools/codeigniter-encryption-key-generator/
<?php
/**
* Generate an encryption key for CodeIgniter.
* http://codeigniter.com/user_guide/libraries/encryption.html
*/
// http://www.itnewb.com/v/Generating-Session-IDs-and-Random-Passwords-with-PHP
function generate_token ($len = 32)
{
@reactormade
reactormade / responsive-facebook-comments.css
Created February 13, 2014 21:02
Responsive Facebook Comments box CSS
.fb_iframe_widget > span {
}
.fb-comments,
.fb-comments iframe[style],
.fb-comments > span {
width: 100% !important;
}
@loganlinn
loganlinn / do.sh
Created March 22, 2012 23:00
PHP strcmp+strtolower VS strcasecmp Benchmark
for i in 50 100 250 500; do echo "String length: $i"; php strcmpbench.php $i; php strcasecmpbench.php $i; echo "\n"; done
# Example run:
#
# String length: 50
# ************************
# * strcomp + strtolower *
# ************************
# Time: 0.000082
# Memory: 1456
@vkarpov15
vkarpov15 / text.md
Last active May 16, 2022 20:26
Caching API Requests With Long-Lived Workflows in Temporal

There is no time limit on Temporal Workflow Executions. You can write a Workflow that runs forever, storing some state and responding to Signals and Queries that come in, as long as you remember to Continue As New. One neat use case for long-lived Workflows is caching API requests.

For example, suppose you want to display prices in different currencies based on cached exchange rates. Exchange rate APIs are often expensive for high volumes of requests, so caching can be worthwhile as long as stale data isn't a problem for your use case. You can create a single Temporal Workflow that makes 1 API request per day to get the latest exchange rates for a set of currencies, and stores the most recent result, with no explicit database calls or cron jobs. In this blog post, I'll describe how you can write an API caching Workflow for the [moneyconvert.net API](https://moneyconvert.net

@Herz3h
Herz3h / install.md
Last active June 14, 2022 18:18
Locales alpine 3.9

Copy locale.md file below into same directory as your Dockerfile

FROM alpine:3.9

# Install language pack
RUN apk --no-cache add ca-certificates wget && \
    wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub && \
    wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.25-r0/glibc-2.25-r0.apk && \
@selfboot
selfboot / centos_python.sh
Last active June 8, 2023 14:11
CentOS 6.8: Install Python 2.7.10, pip, virtualenv, and virtualenvwrapper on CentOS
#!/bin/bash
# According to:
# How To Set Up Python 2.7.6 and 3.3.3 on CentOS 6.4
# https://www.digitalocean.com/community/tutorials/how-to-set-up-python-2-7-6-and-3-3-3-on-centos-6-4
yum -y update
yum groupinstall -y 'development tools'
yum install -y zlib-dev openssl-devel sqlite-devel bzip2-devel
yum install xz-libs
wget http://www.python.org/ftp/python/2.7.10/Python-2.7.10.tar.xz
@supairish
supairish / gist:2951524
Created June 18, 2012 23:58
Nginx - how to limit requests by User Agent
http {
map $http_user_agent $limit_bots {
default '';
~*(google|bing|yandex|msnbot) $binary_remote_addr;
}
limit_req_zone $limit_bots zone=bots:10m rate=1r/m;
server {
@kmjones1979
kmjones1979 / nginx.conf
Last active October 1, 2023 15:50
Example NGINX configuration to route based on country code using GeoIP
# load dynamic modules
load_module /etc/nginx/modules/ngx_http_geoip_module.so;
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log info;
pid /var/run/nginx.pid;
events { worker_connections 1024; }
http {
@davidtheclark
davidtheclark / isElementInViewport.js
Created May 4, 2013 02:00
JavaScript: Is element in viewport?
/*
No jQuery necessary.
Thanks to Dan's StackOverflow answer for this:
http://stackoverflow.com/questions/123999/how-to-tell-if-a-dom-element-is-visible-in-the-current-viewport
*/
function isElementInViewport(el) {
var rect = el.getBoundingClientRect();
return (
rect.top >= 0 &&