This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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}") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ruby -run -e httpd . -p 9090 | |
# iptables -A INPUT -p tcp -m tcp --dport 9090 -j ACCEPT | |
# iptables -F |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 / { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.IO; | |
namespace Rotate | |
{ | |
class Program | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream> | |
#include<map> | |
using namespace std; | |
map<char, int> t9; | |
void solve() { | |
char prev = -1, cur; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Diagnostics; | |
namespace pandigital | |
{ | |
class Program | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Diagnostics; | |
using System.Threading.Tasks; | |
namespace sqr | |
{ | |
class result |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Diagnostics; | |
namespace sqr | |
{ | |
class Program | |
{ |