Skip to content

Instantly share code, notes, and snippets.

View ebababi's full-sized avatar

Nikolaos Anastopoulos ebababi

View GitHub Profile
require 'digest/sha1'
require 'net/http'
def pwned?(password)
digest = Digest::SHA1.hexdigest(password).upcase
prefix = digest[0,5]
suffix = digest[5,256]
uri = URI.parse("https://api.pwnedpasswords.com/range/" + prefix)
@mhluska
mhluska / resume_json.rb
Last active March 3, 2017 23:42
Jekyll plugin for blog post on syncing resume with LinkedIn profile: http://mhluska.com/blog/2014/08/20/syncing-a-jekyll-blog-resume-with-your-linkedin-profile/
# _plugins/resume_json.rb
require 'oauth'
require 'yaml'
require 'json'
module Jekyll
class Resume < Jekyll::Generator
def format_date(date)
Date.new(date['year'], date['month']).strftime('%b %Y').to_s
@ebababi
ebababi / functions.php
Created October 4, 2011 12:42
Cache FeedBurner circulation (subscribers) results in PHP
<?php
function get_feedburner_circulation($feedburner_id, $ttl = 86400) {
$cache = dirname(__FILE__) . '/cache/feedburner.txt';
// Check cache validity
if ( !file_exists($cache) || ( filemtime($cache) + $ttl - time() < 0 ) ) {
// try to get the feed data
$curl = curl_init('https://feedburner.google.com/api/awareness/1.0/GetFeedData?uri=' . $feedburner_id);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($curl);
@brenttheisen
brenttheisen / factory_girl.rake
Created June 24, 2011 20:17
Rake task that loads factories using factory_girl in to the current environment's database. Intended to be a replacement for Rail's rake db:fixtures:load.
#
# To install copy this file in to <RAILS_APP>/lib/tasks/factory_girl.rake.
# To use run: rake db:factory_girl_load
#
namespace :db do
namespace :factory_girl do
desc 'Load Factory Girl factories into the current environment\'s database.'
task :load => :environment do
FactoryGirl.registry.each do |(name, factory)|
FactoryGirl.build name