Skip to content

Instantly share code, notes, and snippets.

@pif
pif / tags.sql
Last active August 21, 2018 12:45
---- 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 February 22, 2018 09:17
This one-liner let's you securely check your password against @troyhunt's DB of 500M pwned passwords.
# @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.
//////////// Exercise Web Crawler / Golang
package main
import (
"fmt"
)
type Fetcher interface {
// Fetch returns the body of URL and
@pif
pif / gist:c59a9cae30983b6e7bc5
Created March 25, 2015 21:04
Move all Dropbox Camera Uploads files to separate folders. New folder format is YYYY_MM_DD. E.g.: 2015_01_22
~/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 December 27, 2015 02:39
Google Glass gestures support for your APK
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 October 31, 2013 17:10
Add SSL Proxy support for Glass Mirror API Java Sample
/**
* 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;
/* -*- 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 October 16, 2012 14:41
get linux/java/flash version
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
@pif
pif / ui-hw-task.java
Created March 1, 2012 11:12
ui-hw-task
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;
@pif
pif / Node.java
Created March 1, 2012 08:23
Node class
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;