Skip to content

Instantly share code, notes, and snippets.

View Ajedi32's full-sized avatar

Andrew Meyer Ajedi32

View GitHub Profile
anonymous
anonymous / Place.py
Created April 1, 2017 05:31
/r/place bot
import requests
from time import sleep
class Place(object):
def __init__(self, user, passwd, greedy=False):
"""
user: reddit username
pass: reddit password
greedy: keep trying to perform request
"""
@alexandrusavin
alexandrusavin / binds_on_mount.sh
Last active February 4, 2024 14:48
Add letsencrypt certificate to dd-wrt web interface
#!/bin/sh
if [ `nvram get https_enable` -gt 0 ] ; then
# get the absolute directory of the executable
SELF_PATH=$(cd -P "$(dirname "$0")" && pwd -P)
echo SELF_PATH: ${SELF_PATH}
# extract the mount path
@maphew
maphew / generateQDS.ps1
Last active January 25, 2022 22:02
Generates a Query Directory Service file which runs a search for the %USERNAME% environment variable in the Windows integrated search tool. Adapted from "How to generate a QDS files which runs a user or group search" by FS76. In support of http://community.spiceworks.com/topic/278782-allow-users-to-update-their-own-information-in-active-directory
cls
# Author: Frank Schneider
# Date: 2015-04-20
# Version:1.0
# Synopsis:
# this sample script generates a QDS file which runs a search for the
# string "Domain Users" in the Windows integrated search tool.
# https://gallery.technet.microsoft.com/scriptcenter/How-to-generate-a-QDS-05fe4ff5
@betesh
betesh / Gemfile
Last active September 18, 2022 04:15
how to append a has_many association without hitting the database immediately
source 'https://rubygems.org'
gem 'activerecord', '~> 3.2.18'
gem 'sqlite3', '= 1.3.5'
gem 'rspec'
@demisx
demisx / active_record_objects_autosave.md
Last active April 29, 2024 09:02
When Active Record Child Objects are Autosaved in Rails

belongs_to:

  1. Assigning an object to a belongs_to association does not automatically save the object. It does not save the associated object either.

has_one:

  1. When you assign an object to a has_one association, that object is automatically saved (in order to update its foreign key).
  2. In addition, any object being replaced is also automatically saved, because its foreign key will change too
  3. If either of these saves fails due to validation errors, then the assignment statement returns false and the assignment itself is cancelled.
  4. If the parent object (the one declaring the has_one association) is unsaved (that is, new_record? returns true) then the child objects are not saved. They will automatically when the parent object is saved.
@willurd
willurd / web-servers.md
Last active May 4, 2024 07:22
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@datagrok
datagrok / git-branch-simplify.md
Last active April 16, 2024 17:26
How to simplify the graph produced by git log --graph

Ideas for improvements to git log --graph

I will maybe someday get around to dusting off my C and making these changes myself unless someone else does it first.

Make the graph for --topo-order less wiggly

Imagine a long-running development branch periodically merges from master. The git log --graph --all --topo-order is not as simple as it could be, as of git version 1.7.10.4.

It doesn't seem like a big deal in this example, but when you're trying to follow the history trails in ASCII and you've got several different branches displayed at once, it gets difficult quickly.

@dpwright
dpwright / .gitconfig
Created June 26, 2012 06:14
Git alias to amend a specific commit earlier in the tree
amend-commit = "!f() { START=`(git symbolic-ref -q HEAD || git rev-parse HEAD) | cut -d"/" -f 3`; git checkout -q $1 && git commit --amend && git rebase --onto HEAD $1 $START; }; f"
@finack
finack / application.rb
Created March 17, 2012 06:18
Example Chef Deploy Revision for Rails 3+
app = node[:rails][:app]
rails_base app[:name] do
ruby_ver app[:ruby_ver]
gemset app[:gemset]
end
%w{config log pids cached-copy bundle system}.each do |dir|
directory "#{app[:app_root]}/shared/#{dir}" do
owner app[:deploy_user]
@lenary
lenary / gitconfig.ini
Created February 18, 2011 01:21
a special excerpt of my gitconfig
$ git clone github:lenary/guides.git
Cloning into guides...
remote: Counting objects: 255, done.
remote: Compressing objects: 100% (216/216), done.
remote: Total 255 (delta 111), reused 163 (delta 35)
Receiving objects: 100% (255/255), 1.49 MiB | 564 KiB/s, done.
Resolving deltas: 100% (111/111), done.
$ cd guides
$ git remote -v