Skip to content

Instantly share code, notes, and snippets.

View tags.sql
---- Query 1: query all dataset and write presence of tags into temp table `tags_counts`
SELECT
url,
CAST(REGEXP_CONTAINS(body, r'(?i)<div\s[^>]*\s*onclick\s*=\s*') AS INT64) tag_div,
CAST(REGEXP_CONTAINS(body, r'(?i)<a\s[^>]*\s*onclick\s*=\s*') AS INT64) tag_a,
CAST(REGEXP_CONTAINS(body, r'(?i)<button\s') AS INT64) tag_button,
CAST(REGEXP_CONTAINS(body, r'(?i)<input\s[^>]*\s*type\s*=\s*[\'"]button[\'"]') AS INT64) tag_input
FROM
`httparchive.response_bodies.2018_08_01_desktop`
WHERE page = url
@pif
pif / pwnedpasswords.sh
Created Feb 22, 2018
This one-liner let's you securely check your password against @troyhunt's DB of 500M pwned passwords.
View pwnedpasswords.sh
# @troyhunt collected 500M passwords in "Pwned Passwords v2" DB.
# This is the one-liner for checking your password against that DB with the support of k-Anonymity.
# k-Anonymity means his website won't know the password you check.
# Read more about the DB & k-Anonymity in this blogpost: https://www.troyhunt.com/ive-just-launched-pwned-passwords-version-2/
# Usage:
# 1. Execute in bash/zsh.
# 2. Enter your password.
# 3. If it outputs nothing -- your password didn't appear in the DB.
# Otherwise it will show how many times that password appeared in the breaches.
View webcrawler.go
//////////// Exercise Web Crawler / Golang
package main
import (
"fmt"
)
type Fetcher interface {
// Fetch returns the body of URL and
@pif
pif / gist:c59a9cae30983b6e7bc5
Created Mar 25, 2015
Move all Dropbox Camera Uploads files to separate folders. New folder format is YYYY_MM_DD. E.g.: 2015_01_22
View gist:c59a9cae30983b6e7bc5
~/D/Camera Uploads ❯❯❯ IFS=$'\n'; for f in $(ls | cat)
do
folder=$(echo $f | sed "s/\(\) \([0-9][0-9]\.[0-9][0-9]\.[0-9][0-9].*\)/\1/g" | sed "s/-/_/g")
echo "Moving $f to $folder"
mv $f ~/BACKUP/$folder
done
@pif
pif / GlassGestures.java
Last active Dec 27, 2015
Google Glass gestures support for your APK
View GlassGestures.java
package com.example.utils;
import android.content.Context;
import android.util.Log;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.widget.Toast;
public class GlassGestures implements GestureDetector.OnGestureListener {
@pif
pif / MirrorClient.java
Created Oct 31, 2013
Add SSL Proxy support for Glass Mirror API Java Sample
View MirrorClient.java
/**
* Subscribes to notifications on the user's timeline.
*/
public static Subscription insertSubscription(Credential credential, String callbackUrl,
...
// Rewrite "appspot.com" to "Appspot.com" as a workaround for
// http://b/6909300.
callbackUrl = callbackUrl.replace("appspot.com", "Appspot.com");
// add ssl proxy
callbackUrl = "https://mirrornotifications.appspot.com/forward?url=" + callbackUrl;
View PApplet.java
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
Part of the Processing project - http://processing.org
Copyright (c) 2004-12 Ben Fry and Casey Reas
Copyright (c) 2001-04 Massachusetts Institute of Technology
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@pif
pif / gist:3899691
Created Oct 16, 2012
get linux/java/flash version
View gist:3899691
uname -a; echo "ISSUE:"; cat /etc/issue; echo "VERSION:"; cat /etc/*version*; echo "RELEASE:"; cat /etc/*release*
java -version; echo "ALTERNATIVES: "; update-alternatives --list java
apt-cache show adobe-flashplugin
View ui-hw-task.java
package ua.edu.lnu.pif.ucs;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.InputEvent;
import java.awt.geom.Point2D;
import java.util.ArrayList;
import java.util.Random;
import edu.umd.cs.piccolo.PCanvas;
View Node.java
package ua.edu.lnu.pif.ucs;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
import java.util.Map;
import java.util.TreeMap;