Skip to content

Instantly share code, notes, and snippets.

@siddartha
siddartha / index.html
Created September 19, 2019 10:15 — forked from bwarner/index.html
Example of auto refreshing ads
<!DOCTYPE html>
<html>
<head>
<script async="async" src="https://www.googletagservices.com/tag/js/gpt.js"></script>
<script async src="//acdn.adnxs.com/prebid/not-for-prod/1/prebid.js"></script>
<script>
var googletag = googletag || {};
googletag.cmd = googletag.cmd || [];
var pbjs = pbjs || {};
@siddartha
siddartha / local_db_test.py
Created January 7, 2018 20:54 — forked from macloo/local_db_test.py
Test your MySQL database connection for Flask-SQLAlchemy
#!/Users/username/Documents/python/projectname/env/bin/python
# change username and projectname above to match yours - the path must match the path in YOUR virtualenv
"""
edit line 1 to match what YOU get when you are in YOUR virtualenv and type:
which python
# NO SPACES in first 3 chars in line 1: #!/
# make sure env is activated!
<?php
$today = date("Y-m-d");
$month = date("Y-m"); $mpattern = '/^'.$month.'/';
$yesterday = date('Y-m-d', strtotime("1 day ago" ));
foreach ($metrics_global as $k => $row) {
// DEBUG echo $k."-(".$row['met_date']." / ".$row['earn'].")<br />";
$total+= $row['earn'];
if (in_array($yesterday, $row)) {$hier = $row['earn'];}
from django.db import models
from django.contrib.auth.models import User
# Create your models here.
class Site(models.Model):
user = models.ForeignKey(User)
site = models.CharField(max_length=255)
def __unicode__(self):
return self.site
#!/usr/bin/env python
# -*- coding: utf-8 -*-
set1 = open('set1.txt','r')
set2 = open('set2.txt','r')
output = open('diff.txt','w')
eachhost1 = set1.read().splitlines()
#print eachhost1
eachhost2 = set2.read().splitlines()
def ajout(request):
if request.method == "POST":
lien_form = LienForm(request.POST)
ancre_form = AncreForm(request.POST)
if lien_form.is_valid():
lien = Lien()
lien.date = lien_form.cleaned_data['date']
lien.url = lien_form.cleaned_data['url']
lien.page = lien_form.cleaned_data['page']
lien.typeLien = lien_form.cleaned_data['typeLien']
# forms.py
from django import forms
from django.contrib.auth.models import User
class ConnexionForm(forms.Form):
username = forms.CharField(label="Nom d'utilisateur", max_length=30)
password = forms.CharField(label="Mot de passe", widget=forms.PasswordInput)
<?php
// http://clients1.google.com/complete/search?hl=fr&output=toolbar&q=gestion%20des%20logs
$query = urlencode($_GET['q']);
$uri = "http://clients1.google.com/complete/search?hl=fr&output=toolbar&q=".$query;
/* gets the data from a URL */
function get_data($url) {
$ch = curl_init();
<?php
// http://clients1.google.com/complete/search?hl=fr&output=toolbar&q=gestion%20des%20logs
$q = $argv[1];
$url = "http://clients1.google.com/complete/search?hl=fr&output=toolbar&q=".urlencode($q);
/* gets the data from a URL */
function get_data($url) {
$ch = curl_init();
@siddartha
siddartha / optiJPG.sh
Created April 7, 2013 10:43
Script SHELL à placer à la racine du dossier d'images à optimiser.
#!/bin/sh
# optiJPG.sh: a sample shell script to launch JPG optimisation
# via: find ./ -type f -name '*.jpg' -exec ./optiJPG.sh {} \;
# TODO define usage function
for f; do
jpegtran -copy none -optimize -perfect -outfile $f $f
echo $f OK..
done