Skip to content

Instantly share code, notes, and snippets.

@zulhfreelancer
zulhfreelancer / heroku_pg_db_reset.md
Last active June 17, 2024 11:44
How to reset PG Database on Heroku (for Rails app)?

It's important to note that running this reset will drop any existing data you have in the application

How to reset PG Database on Heroku?

  • Step 1: heroku restart
  • Step 2: heroku pg:reset DATABASE (no need to change the DATABASE)
  • Step 3: heroku run rake db:migrate
  • Step 4: heroku run rake db:seed (if you have seed)

One liner

var numberOfUsers = 3000 // the nubmer of users you want to follow (it will break after about 5000)
function harvest() {
// keep scrolling the page to the bottom
$("#search").scrollTop($("#search")[0].scrollHeight);
// get all the follow buttons
var bs = $('*[data-capture="noiseClicked"]')//.length
// figure out how many follow buttons you have
var len = bs.length
// show the number of people you have on the page because you're impatient
console.log(len)
<VirtualHost *:80>
ServerAdmin systems@example.com
ServerName search.example.com
ProxyPass / http://127.0.0.1:9200/ timeout=90 retry=5
ProxyPassReverse / http://127.0.0.1:9200/ timeout=90 retry=5
<LocationMatch "^/(?!status)">
AuthType Basic
@jayzalowitz
jayzalowitz / bs.php
Created January 27, 2013 00:06
The solution to "Beautiful Strings" on facebook's hackers cup in php https://www.facebook.com/hackercup/problems.php?pid=475986555798659&round=185564241586420
<?php
$case = 0;
$filename = "beautiful_stringstxt";
$facebook = file($filename, FILE_IGNORE_NEW_LINES);
foreach($facebook as $line)
{
$linebeauty = 0;
if (!($case == 0)){
$stack = array();
@branch14
branch14 / ruby-signaturepad-to-image.rb
Created December 11, 2012 14:15
convert json signatures captured by thomasjbradley's signature-pad to an image
# see https://github.com/thomasjbradley/signature-pad for more details
instructions = JSON.load(data).map { |h| "line #{h['mx']},#{h['my']} #{h['lx']},#{h['ly']}" } * ' '
system "convert -size 198x55 xc:transparent -stroke blue -draw '#{instructions}' signature.png"
@marijn
marijn / unshorten.php
Created October 16, 2012 20:52
Unshorten URLS with PHP and CURL
<?php
/**
* @link http://jonathonhill.net/2012-05-18/unshorten-urls-with-php-and-curl/
*/
function unshorten_url($url) {
$ch = curl_init($url);
curl_setopt_array($ch, array(
CURLOPT_FOLLOWLOCATION => TRUE, // the magic sauce
CURLOPT_RETURNTRANSFER => TRUE,