Skip to content

Instantly share code, notes, and snippets.

@ChrisLusted
ChrisLusted / db.rake
Last active September 19, 2016 07:51 — forked from romansklenar/db.rake
Rake tasks to maintain Postgres tables
# lib/tasks/db.rake
namespace :db do
desc 'Maintains database by running command as ANALYZE, VACUUM and REINDEX'
task maintain: :environment do
verbose = ENV['VERBOSE'].present?
connection = ActiveRecord::Base.connection
puts "Maintaining database #{connection.current_database} ..."
connection.execute("VACUUM FULL #{'VERBOSE' if verbose}")
connection.execute("ANALYZE #{'VERBOSE' if verbose}")
@emad-elsaid
emad-elsaid / gist:2c2524440e30a91273ce
Created August 4, 2014 07:12
ruby server and allow port on centos
$ ruby -run -e httpd . -p 9090
# iptables -A INPUT -p tcp -m tcp --dport 9090 -j ACCEPT
# iptables -F
@kyledrake
kyledrake / ferengi-plan.txt
Last active January 10, 2025 14:02
How to throttle the FCC to dial up modem speeds on your website using Nginx
# The blog post that started it all: https://neocities.org/blog/the-fcc-is-now-rate-limited
#
# Current known FCC address ranges:
# https://news.ycombinator.com/item?id=7716915
#
# Confirm/locate FCC IP ranges with this: http://whois.arin.net/rest/net/NET-165-135-0-0-1/pft
#
# In your nginx.conf:
location / {
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace Rotate
{
class Program
{
#include<iostream>
#include<map>
using namespace std;
map<char, int> t9;
void solve() {
char prev = -1, cur;
@mtayseer
mtayseer / euler_38.py
Created March 16, 2014 16:27
Solve project Euler problem #38 http://projecteuler.net/problem=38
# Analysis:
#
# Let's try to find the optimal range. We know that
# 1. 918273645 is a 1-9 pandigital & is a concatenated product, which means that this number is either the largest or
# below it, so we search from this number up
# 2. Then we find that the number we're trying to search for should start with 9, e.g. 9, 91, 945, etc
# 3. len(concat_product(x=90, n=3)) = 8, len(concat_product(x=90, n=4)) = 11. This range won't work.
# 4. len(concat_product(x=9000, n=2)) = 9. This is where we should start.
# 5. Taking #1 in consideration, we will start from 9182 till 9999
# 6. To get the pandigital number from a this range, we can multiply by n * 100000 + n * 2 => n * 100002
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
namespace pandigital
{
class Program
{
from bottle import route, run, template, request
index_template = '''<table width=100% height=100% border=1>
<tr>
<td width=50%>
<textarea style="width: 100%; height: 100%"></textarea>
</td>
<td>
<div id="result">
</div>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Threading.Tasks;
namespace sqr
{
class result
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
namespace sqr
{
class Program
{