Skip to content

Instantly share code, notes, and snippets.

#include <stdio.h>
#include <assert.h>
#include <stdint.h>
uint16_t rgb888torgb565(uint8_t *rgb888Pixel)
{
uint8_t red = rgb888Pixel[0];
uint8_t green = rgb888Pixel[1];
uint8_t blue = rgb888Pixel[2];
before_script:
- rbenv local 2.3.0
- gem install bundler --no-ri --no-rdoc
- bundle install --jobs $(nproc) "${FLAGS[@]}"
stages:
- test
- deploy
test:
def panel(heading, options = {}, &block)
title = content_tag(:h3, heading, class: 'panel-title')
content_tag(:div,
content_tag(:div, title, class: 'panel-heading') +
content_tag(:div, capture(&block), class: 'panel-body'),
options.reverse_merge({class: "panel panel-default"}))
end
def modal(heading, options = {}, &block)
close_button = content_tag(:button, '&times;'.html_safe, class: 'close', data: { dismiss: 'modal' })
@ramblex
ramblex / chosen_helper.rb
Last active December 25, 2015 06:49
RSpec + chosen.js v1.0 single select helper
def select_from_chosen(item_text, options)
field_name = options[:from]
# Find the field
field = find_field(field_name, visible: false)
# Open the Chosen drop down
page.execute_script(%Q!$("##{field[:id]}_chosen").mousedown()!)
# Simulate text being typed
typed_text = ""
item_text.chars.each do |char|
require 'benchmark'
n = 1000000
b = "b string".freeze
Benchmark.bmbm do |x|
x.report("use interpola") { n.times do; a = 'a string'; "#{a} #{b}"; end}
x.report("concat single") { n.times do; a = 'a string'; a + b; end}
x.report("use << single") { n.times do; a = 'a string'; a << b; end}
end
@ramblex
ramblex / log
Created September 4, 2012 16:24
STDOUT.sync = true
require 'tdriver'
include TDriverVerify
puts "Connect SUT"
@sut = TDriver.connect_sut(:Id => 'sut_qt')
puts "Check dialogfixture"
MobyUtil::Parameter[:sut_qt][:fixtures][:dialog] = "dialogfixture"
puts "-------------------"
def show
@company = Company.find(params[:id])
end
get_info.execute.each do |row|
res_output = "#{res_output} #{place}: #{row[0]} (#{row[1]});"
place += 1
end
@ramblex
ramblex / hack.sh
Created March 31, 2012 17:08 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
<!doctype html>
<html>
<head>
<title>Example double confirm</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#submit-button').click(function() {
var confirm1 = confirm('Are you sure?');
if (confirm1 === true) {