Skip to content

Instantly share code, notes, and snippets.

@crossphd
crossphd / dog.rb
Created August 22, 2016 12:09
Firehose Quiz 3: Dog Class
class Dog
attr_accessor :name
def initialize(name)
@name = name
end
def talk
puts "woof woof"
@crossphd
crossphd / 404-cool-display.markdown
Created October 8, 2016 15:45
404 cool display
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Written as part of https://www.scrapehero.com/how-to-scrape-amazon-product-reviews-using-python/
from lxml import html
import json
import requests
import json,re
from dateutil import parser as dateparser
from time import sleep
@crossphd
crossphd / scrape.rb
Created May 16, 2017 16:50 — forked from jescalan/scrape.rb
Ruby Amazon Scraper
require 'rubygems'
require 'nokogiri'
require 'open-uri'
require 'colored'
# this is just a preview of what's to come - a proof of concept.
# it will be converted to a api-type library, gemified, and put in it's own repo
# for now, a cool way to experiment with amazon's data
query = 'ruby'
Article currentArticle = getItem(position);
ImageView image = listItemView.findViewById(R.id.article_image);
if (currentArticle != null) {
new DownloadImageTask(image).execute(currentArticle.getmImageUrl());
}
private class DownloadImageTask extends AsyncTask<String, Void, Bitmap> {
ImageView bmImage;
public DownloadImageTask(ImageView bmImage) {
this.bmImage = bmImage;
}
protected Bitmap doInBackground(String... urls) {
String urldisplay = urls[0];
Bitmap bmp = null;
try {
compile 'com.squareup.picasso:picasso:(insert latest version)'
<dependency>
<groupId>com.squareup.picasso</groupId>
<artifactId>picasso</artifactId>
<version>(insert latest version)</version>
</dependency>
Article currentArticle = getItem(position);
ImageView image = listItemView.findViewById(R.id.article_image);
if (currentArticle != null) {
Picasso.with(this.getContext())
.load(currentArticle.getmImageUrl())
.centerCrop()
.transform(new CircleTransform(50,0))
.fit()
import android.graphics.Bitmap;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.RectF;
import android.graphics.Shader;
import com.squareup.picasso.Transformation;
public class CircleTransform implements Transformation {