Skip to content

Instantly share code, notes, and snippets.

@Phlip
Phlip / gist:f79b3b5bd44663b3bd72e173fc5dce13
Created December 28, 2023 16:37
AchartEngine bug in addFillOutsideLine()
package com.example.achartengineexample;
import android.graphics.Color;
import android.os.Bundle;
import android.widget.LinearLayout;
import androidx.appcompat.app.AppCompatActivity;
import org.achartengine.ChartFactory;
import org.achartengine.GraphicalView;
import org.achartengine.chart.PointStyle;
import org.achartengine.model.XYMultipleSeriesDataset;
import org.achartengine.model.XYSeries;
@Phlip
Phlip / assert_agile.rb
Created May 16, 2020 03:23
assert_xpath, assert_latest, assert_yin_yang
require 'test_helper'
require 'nokogiri'
require 'pp'
class WelcomeControllerTest < ActionController::TestCase
# Someone currently working in Ruby on Rails or similar should
# put these into Ruby gems ktx
##
@Phlip
Phlip / LineChart.java
Last active March 3, 2020 14:45
fix bug in AChartEngine's legend, where the sample line didn't pick up its series's Stroke setting
/*
AChartEngine has a bug. In a Series, such as an XYSeries or TimeSeries, if you set a Stroke,
such as myXYRenderer.setStroke(BasicStroke.DASHED), the line appears dashed. But the sample line
down in the legend, while the correct color, is not dashed.
The fix is to get into LineChart.java and make drawLegendShape() look a little bit like this:
*/
public void drawLegendShape(Canvas canvas, SimpleSeriesRenderer renderer, float x, float y,
int seriesIndex, Paint paint) {
require 'rubygems'
require 'twitter'
# Read https://developer.twitter.com/en/apps/3851951 to get the access
# keys for your Twitter account
client = Twitter::REST::Client.new do |config|
config.consumer_key = "secret"
config.consumer_secret = "secret"
config.access_token = "secret"
@Phlip
Phlip / should_be_html_with_spec.rb
Created March 9, 2009 06:34
An RSpec HTML matcher that nests contexts
=begin
Note that assert{ 2.0 }'s assert_xhtml (and .be_html_with) now supersede this Gist! Get them with
gem install nokogiri assert2
require 'assert2/xhtml'
And see: http://groups.google.com/group/merb/browse_thread/thread/3588d3f75fa0e65c
----8<---------------------------
require 'nokogiri'
=begin
from_xml{} and convert{} form a light DSL to convert XML
(such as to_xml() provides) into a matching new or updated
ActiveRecord object model. The DSL provides numerous hooks
and optional callbacks to rename and reprocess custom
XML, allowing it to range from a direct translation
to a complete reinterpretation of the represented objects.