Skip to content

Instantly share code, notes, and snippets.

View dimasusername's full-sized avatar
🏇

Dmitrii Kharlamov dimasusername

🏇
View GitHub Profile
@yershalom
yershalom / get_commit_count.py
Created December 17, 2017 13:19
Easy way to calculate commits count from the github api
import requests
base_url = 'https://api.github.com'
def get_all_commits_count(owner, repo, sha):
first_commit = get_first_commit(owner, repo)
compare_url = '{}/repos/{}/{}/compare/{}...{}'.format(base_url, owner, repo, first_commit, sha)
commit_req = requests.get(compare_url)
@wearethefoos
wearethefoos / syntax.md
Created November 4, 2016 11:24
Ruby vs JS vs ES6

Variables

Ruby

Name a value.

color = "red"
@caseywatts
caseywatts / Gemfile
Last active February 19, 2020 21:23
Sinatra on Cloud9
source 'https://rubygems.org'
gem 'sinatra'
gem 'sinatra-contrib'

I got hit by the weird group reassignment when I upgraded to Mavericks. In my case the group was macports (!). I’ve seen one report from a user who got cloakproxy after the 10.11 upgrade, so apparently the bug is still there.

For some reason the OS X upgrader sometimes picks a group and changes the PrimaryGroupID to 20. Here’s the confirm:

dscl . -read Groups/cloakproxy
dscl . -read Groups/staff

And the fix:

@alperg
alperg / index.html
Created November 9, 2015 19:01
Github Repo Search API
<h2>Github Search API: Quantify Frameworks</h2><input type="text" placeholder="Username" id="username">
<h4><button onclick="get()">GET</button></h4>
<p>Response:</p>
<pre id="a"></pre>
@ygotthilf
ygotthilf / jwtRS256.sh
Last active September 16, 2025 08:53
How to generate JWT RS256 key
ssh-keygen -t rsa -b 4096 -m PEM -f jwtRS256.key
# Don't add passphrase
openssl rsa -in jwtRS256.key -pubout -outform PEM -out jwtRS256.key.pub
cat jwtRS256.key
cat jwtRS256.key.pub
@afilhodaniel
afilhodaniel / gist:09a1df8eafeabe1584c6
Last active November 12, 2020 10:20
Upload photos to Instagram via private API with Ruby
class InstagramPrivateController < ApplicationController
def initialize(username, password, photo, caption)
@username = username
@password = password
@photo = photo
@caption = caption
@cookiepath = Tempfile.new('cookies').path
@user_agent = generate_user_agent()
@montanaflynn
montanaflynn / easyget.go
Last active September 12, 2020 17:44
GET JSON array in Golang
package easyget
import (
"io"
"io/ioutil"
"net/http"
)
// Define Request struct
type Request struct {
@kany
kany / redis-resque-stuff.md
Last active June 28, 2022 05:33
Clearing dead/stuck/zombie Resque workers redis resque delayed_job

$ rails c

Loading development environment (Rails 3.1.3)
1.9.3p0 :002 > Resque::Worker.working.each{|w| w.done_working}

$ redis-cli

# Removes data from your connection's CURRENT database.
@amitsaxena
amitsaxena / gist:6977506
Last active February 7, 2017 18:33
How to get object creation timestamp from BSON object id using mongoid, and do range queries on it.
# To get the created at timestamp
sample_object.id.generation_time
# To do range queries
start = Moped::BSON::ObjectId.from_time(Time.now.beginning_of_day)
finish = Moped::BSON::ObjectId.from_time(Time.now.end_of_day)
MyModel.where(:id => {'$gt' => start, '$lt' => finish}).count