Skip to content

Instantly share code, notes, and snippets.

View askedrelic's full-sized avatar

Matt Behrens askedrelic

View GitHub Profile
from flask import Flask, session
app = Flask(__name__)
app.session = dict()
@app.route('/')
def reset():
app.session["counter"]=0
@askedrelic
askedrelic / dates.py
Last active November 22, 2020 19:41
Python formatted dates #python
import arrow
dates = [arrow.now().replace(days=x).format('YYYY-MM-DD') for x in range(90)]
for x in dates: print x
@askedrelic
askedrelic / gist:897652
Created April 1, 2011 02:50
toggle audio source on OSX
set the currentSource to (do shell script "/Users/askedrelic/bin/SwitchAudioSource -c")
if currentSource is equal to "Built-in Output" then
do shell script "/Users/askedrelic/bin/SwitchAudioSource -s \"Built-in Line Output\""
else
do shell script "/Users/askedrelic/bin/SwitchAudioSource -s \"Built-in Output\""
end if
@askedrelic
askedrelic / trim.sh
Created August 15, 2017 08:23
Unix Trim
cut -c1-8
@askedrelic
askedrelic / debugging
Created August 15, 2017 08:22
Ansible snippets
- debug: var=another_fact
- name: Perform a rot13
debug: msg="The word {{ roman_name }} becomes {{ roman_name | rot13 }}"
- name: get hostvars for servers' ansible_default_ipv4
set_fact:
ip_list1: "{{ hostvars|fetchlistfromdict(groups.servers)|map(attribute='ansible_default_ipv4.address')|list }}"
- name: turn to FOO
@askedrelic
askedrelic / better move
Last active August 15, 2017 08:18
Find examples #unix
# better mv
find . -name "*.symlink" -exec sh -c 'echo "$1" ".${1%.symlink}"' _ {} \;
@askedrelic
askedrelic / ruby-help.sh
Created August 15, 2017 08:15
Ruby gems help
# install Gemfile
bundle
bundle lock
gem install
# uninstall all unnecesary gems
gem cleanup
@askedrelic
askedrelic / todo.js
Created August 15, 2017 08:13
Simple React TODO app #react
<script type="text/babel">
var SAMPLE_DATA = [
{"unread": false, "desc": "Hey, I just wanted to check in with you from Toronto. I got here earlier today.", "name": "Tilo Mitra", "avatar": "http://api.twitter.com/1/users/profile_image?screen_name=tilomitra&amp;size=bigger", "subject": "Hello from Toronto", "timestamp": "3:56pm, April 3, 2012", "content": "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat."},
{"unread": true, "desc": "Hey, I had some feedback for pull request #51. We should center the menu so it looks better on mobile.", "name": "Eric Ferraiuolo", "avatar": "http://api.twitter.com/1/users/profile_image?screen_name=yuilibrary&amp;size=bigger", "subject": "Re: Pull Requests", "timestamp": "2:27pm, April 3, 2012", "content": "Duis aute irure dolor in reprehenderit in voluptate velit essecillum dolore eu fugiat null
@askedrelic
askedrelic / gist:4597730
Last active August 15, 2017 07:49
Timezones array
TIMEZONES = [
('Pacific/Pago_Pago', "-11:00 - Samoa, Midway Island"),
('America/Adak', "-10:00 - Aleutian Islands"),
('Pacific/Honolulu', "-10:00 - Hawaii"),
('Pacific/Marquesas', "-09:30 - Marquesas Islands"),
('Pacific/Gambier', "-09:00 - Gambier Islands"),
('America/Anchorage', "-09:00 - Alaska"),
('America/Los_Angeles', "-08:00 - US Pacific Time (US & Canada)"),
('Pacific/Pitcairn', "-08:00 - Pitcairn Islands"),
('America/Phoenix', "-07:00 - Arizona Mountain Standard Time"),