Skip to content

Instantly share code, notes, and snippets.

Shiplu Mokaddim shiplunc

Block or report user

Report or block shiplunc

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@shiplunc
shiplunc / raspberrypi1.py
Created Dec 3, 2015
Turn Red Green lights on off etc.
View raspberrypi1.py
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)
View execute-command-per-10-seconds-in -cron.bash
#!/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 / mysql-scripts.sh
Last active Aug 29, 2015
Find incremental .sql scripts from git
View mysql-scripts.sh
#!/bin/bash
git log --stat --reverse --since='2014-07-05 00:00:00' -- mysql-scripts | grep -E 'mysql-scripts\S+' -o | uniq
@shiplunc
shiplunc / publisher-list-by-month.py
Last active Aug 29, 2015
Generate Publishers list by month
View publisher-list-by-month.py
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 / bash-session
Last active Aug 29, 2015
mongodump query with date error "FailedToParse: FailedToParse: Bad characters in value"
View bash-session
# 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 / list_shutterstock_image_licenses.py
Last active Aug 29, 2015
List all the image licensed by you. You need to provide access token
View list_shutterstock_image_licenses.py
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 / shutterstock
Created Dec 11, 2014
/etc/logrotate.d/shutterstock file content
View shutterstock
/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 / estimated-time-for-getty-reindex.py
Last active Aug 29, 2015
Estimated time calculator for Getty Re indexing
View estimated-time-for-getty-reindex.py
# 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()
You can’t perform that action at this time.