Skip to content

Instantly share code, notes, and snippets.

View igolden's full-sized avatar
🎯
Focusing

Ian Golden igolden

🎯
Focusing
View GitHub Profile
@nicolashery
nicolashery / environment-variables-jekyll-templates.md
Last active January 22, 2023 15:56
Make environment variables available in Jekyll Liquid templates

Environment variables in Jekyll templates

This is one way to pass some data (API tokens, etc.) to your Jekyll templates without putting it in your _config.yml file (which is likely to be committed in your GitHub repository).

Copy the environment_variables.rb plugin to your _plugins folder, and add any environment variable you wish to have available on the site.config object.

In a Liquid template, that information will be available through the site object. For example, _layouts/default.html could contain:

@schickling
schickling / Rakefile
Last active January 31, 2024 23:00
Activerecord without Rails
require "active_record"
namespace :db do
db_config = YAML::load(File.open('config/database.yml'))
db_config_admin = db_config.merge({'database' => 'postgres', 'schema_search_path' => 'public'})
desc "Create the database"
task :create do
ActiveRecord::Base.establish_connection(db_config_admin)
@datenimperator
datenimperator / sqlite.rb
Created November 22, 2013 16:19
Speed up your Rails sqlite database for large dataset. This should be a Rails initializer, goes into config/initializers.
if ::ActiveRecord::Base.connection_config[:adapter] == 'sqlite3'
if c = ::ActiveRecord::Base.connection
# see http://www.sqlite.org/pragma.html for details
# Page size of the database. The page size must be a power of two between 512 and 65536 inclusive
c.execute 'PRAGMA main.page_size=4096;'
# Suggested maximum number of database disk pages that SQLite will hold in memory at once per open database file
c.execute 'PRAGMA main.cache_size=10000;'
@denji
denji / nginx-tuning.md
Last active May 24, 2024 05:32
NGINX tuning for best performance

Moved to git repository: https://github.com/denji/nginx-tuning

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

/** @jsx React.DOM */
var SVGComponent = React.createClass({
render: function() {
return this.transferPropsTo(
<svg>{this.props.children}</svg>
);
}
});

Using CasperJS to scrape an infinite scroll page

This is a short script to scrape an infinite scroll page and write the resulting HTML to a file

You'll need to install CasperJS; on a Mac that will involve brew install casperjs --devel (if you don't have Homebrew, you can read how to do so here)

To run the script, you can use casperjs scrape.js --ssl-protocol=any from the command line.

@enpe
enpe / CMakeLists.txt
Last active November 25, 2022 04:15
OpenCV chroma key
cmake_minimum_required( VERSION 3.0 )
project( so-opencv-calibration )
find_package( OpenCV 3.0.0 EXACT REQUIRED )
set( INPUT_FILENAME "${CMAKE_CURRENT_LIST_DIR}/input_00.png" ) # Input file, e.g. http://i.stack.imgur.com/WjER0.png
add_executable( mwe mwe.cpp )
target_compile_definitions( mwe PRIVATE -DINPUT_FILENAME="${INPUT_FILENAME}" )
target_include_directories( mwe PRIVATE ${OpenCV_INCLUDE_DIRS} )
target_link_libraries( mwe ${OpenCV_LIBS} )
import React from "react";
import { render } from "react-dom";
const ParentComponent = React.createClass({
getDefaultProps: function() {
console.log("ParentComponent - getDefaultProps");
},
getInitialState: function() {
console.log("ParentComponent - getInitialState");
return { text: "" };
@BretFisher
BretFisher / .travis.yml
Created February 15, 2016 21:26
Travis-CI Docker Image Build and Push to AWS ECR
sudo: required #is required to use docker service in travis
language: php #can be any language, just php for example
services:
- docker # required, but travis uses older version of docker :(
install:
- echo "install nothing!" # put your normal pre-testing installs here
@varyonic
varyonic / docker-compose.yml
Last active May 18, 2021 13:18
Capybara standalone Selenium Chrome config
web:
build: .
volumes:
- .:/opt/myapp
ports:
- '3000:3000'
links:
- db
- redis
- selenium