Skip to content

Instantly share code, notes, and snippets.

View dyjjones's full-sized avatar

Dylan Jones dyjjones

  • Seattle
View GitHub Profile
@dyjjones
dyjjones / unreverse
Created July 5, 2014 02:07
unPythonic reverse
reverse = lambda s: ''.join([c for i,c in sorted(zip(range(len(s)), s), key=lambda c: -c[0])])
reverse('burrito') # otirrub
# Or do it in a single line!
(lambda s: ''.join([c for i,c in sorted(zip(range(len(s)), s), key=lambda c: -c[0])]))('burrito')
@dyjjones
dyjjones / neg.js
Last active August 29, 2015 14:04
Command line function for lat/lon of picture.
//#!/usr/bin/node
// neg = node exif geolocation, latitude and longitude
// Add to your path, then use as: neg.js [path to image]
// chmod +x this file on download, move to a path folder
// or add to path manually
var im = require('imagemagick');
if (process.argv.length === 3) {
var im = require('imagemagick');
var Guid = require('guid');
var siteConf = require('./lib/getConfig');
var lib = new require('./lib/asms-client.js')(app, cf).streamLib;
function ingestPhoto(req, res, next){
if (req.files.image) {
im.identify(req.files.image.path, function(err, features){
if (features && features.width) {
var guid = Guid.create();
@dyjjones
dyjjones / filename_reverser.py
Created August 8, 2014 07:05
Change an mp3's filename from [Singer] - [Song] to [Song] - [Singer] or vice versa
import os
def reverse_filename(s):
split_filename = s.split(" - ")
split_filename.reverse()
new_filename = " - ".join(split_filename)
return new_filename
file_extension = ".mp3"
import sys
import math
def is_prime(n):
if n < 4:
return True
if n % 2 == 0:
return False
for a in range(3, int(math.sqrt(n))+1):
if n % a == 0:
function is_prime(n)
if n < 4
return true
end
if n % 2 == 0
return false
end
for a = 3:int(sqrt(n))
if n % a == 0
return false
program hw2
implicit none
real x
double precision y
double precision z
integer i
double precision h
double precision q
! use f90 or f95 for this
program hw2
implicit none
! vars
double precision :: h, p
integer :: loop
double precision, dimension(11) :: trueVals
h = 1.0
0.4 10.12
0.6 10.21
0.8 10.29
1 10.21
1.2 10.21
1.4 10.12
1.6 10.048
1.8 10.14
2 10.205
2.2 10.12
0.4 9.80
0.6 9.73
0.8 9.82
1 9.73
1.2 9.73
1.4 9.82
1.6 9.65
1.8 9.65
2 9.73
2.2 9.73