Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View shiplunc's full-sized avatar

Shiplu Mokaddim shiplunc

View GitHub Profile
@shiplunc
shiplunc / estimated-time-for-getty-reindex.py
Last active August 29, 2015 14:07
Estimated time calculator for Getty Re indexing
# Put this file on scripts folder and run using following command
# sudo DJANGO_SETTINGS_MODULE=theplatform.settings /root/python-env/bin/python estimated-time-for-getty-reindex.py /home/ubuntu/source-72-combine-getty-assetgroups.checkpoint
import sys
import datetime
def print_progress(filename):
with open(filename, 'r') as f:
content = f.read()
@shiplunc
shiplunc / shutterstock
Created December 11, 2014 09:00
/etc/logrotate.d/shutterstock file content
/var/log/newscred/shutterstock-images.log /var/log/newscred/shutterstock-images.error {
rotate 12
monthly
compress
missingok
notifempty
}
/var/log/newscred/shutterstock-pages.log /var/log/newscred/shutterstock-pages.error {
rotate 12
@shiplunc
shiplunc / list_shutterstock_image_licenses.py
Last active August 29, 2015 14:11
List all the image licensed by you. You need to provide access token
import json
import sys
import urllib2 as ul
from itertools import count
import urllib
from urlparse import urlparse, urlunparse
def build_url(**qs):
params = {'fields': 'data(id,download_time,image/id),total_count',
@shiplunc
shiplunc / bash-session
Last active August 29, 2015 14:16
mongodump query with date error "FailedToParse: FailedToParse: Bad characters in value"
# Check the following bash session carefully to know how this was solved.
# In short I just used the milliseconds with Date function
ubuntu@production-server:~$ mongodump --collection my_collection --db my_db --query '{"timestamp": {$gt: ISODate("2015-02-01T00:
00:00Z")}}'
connected to: 127.0.0.1
assertion: 16619 code FailedToParse: FailedToParse: Bad characters in value: offset:19
ubuntu@production-server:~$ mongodump --collection my_collection --db my_db --query '{"timestamp": {$gt:ISODate("2015-02-01T00:0
0:00Z")}}'
connected to: 127.0.0.1
@shiplunc
shiplunc / publisher-list-by-month.py
Last active August 29, 2015 14:17
Generate Publishers list by month
from datetime import datetime
from analytics import tasks
from analytics.reporting import getty_reporter as gr
from theplatform.newscred.models import User
import calendar
import sys
def get_publisher_of_month(credentials, year, month):
_, end_day = calendar.monthrange(year, month)
@shiplunc
shiplunc / mysql-scripts.sh
Last active August 29, 2015 14:18
Find incremental .sql scripts from git
#!/bin/bash
git log --stat --reverse --since='2014-07-05 00:00:00' -- mysql-scripts | grep -E 'mysql-scripts\S+' -o | uniq
#!/bin/bash
interval=10
times=6
cmd="/path/to/node /path/to/script.js"
start_time=$(date +"%s")
$cmd
for t in `seq $(($times - 1))`
@shiplunc
shiplunc / raspberrypi1.py
Created December 3, 2015 11:18
Turn Red Green lights on off etc.
import time
from RPi import GPIO
green = 17
red = 22
def blink(led, duration, count=10):
time_slice = float(duration)/float(count)
GPIO.setup(led, GPIO.OUT)