Skip to content

Instantly share code, notes, and snippets.

View hanneskaeufler's full-sized avatar
🏠
I may be slow to respond.

Hannes Käufler hanneskaeufler

🏠
I may be slow to respond.
View GitHub Profile
@hanneskaeufler
hanneskaeufler / switch_to_safari.scpt
Created June 1, 2016 19:25
AppleScript to move all the open tabs in Google Chrome to Safari
tell application "Google Chrome"
set allUrls to {}
repeat with theWindow in every window
set urlsInWindow to {}
repeat with theTab in every tab of theWindow
set currentUrl to the theTab's URL
set urlsInWindow to urlsInWindow & {currentUrl}
end repeat
set allUrls to allUrls & {urlsInWindow}
end repeat
<?php
public function test_it_sets_the_full_name() {
$subject = new User();
$name = "Peter";
$subject->setFirstname($name);
$this->assertEquals($name, $subject->getFirstname());
}
<?php
public function test_it_sets_the_full_name() {
$subject = new User();
$subject->setFirstname("Peter");
$this->assertEquals("Peter", $subject->getFirstname());
}
private def single_post(post : Post)
article do
header class: "post-title" do
h2 do
text post.title
link "#", to: Blog::Posts::Show.with(post.slug)
end
post_meta(post)
end
content(post)
def __render_row(self, row):
self.__render_project_name(row)
+ self.__render_project_status(row)
+
+ def __render_project_status(self, row):
+ start_y = (row[0] + 1) * self.__row_height()
+ badge_width = 150
+ padding = 10
+ pos = (self.__from_right(badge_width), start_y + padding, self.__from_right(padding), start_y + self.__row_height() - padding)
+ self.draw.rectangle(pos, outline = self.BLACK)
padding = 10
pos = (self.__from_right(badge_width), start_y + padding, self.__from_right(padding), start_y + self.__row_height() - padding)
self.draw.rectangle(pos, outline = self.BLACK)
- self.draw.text((self.__from_right(badge_width + 35), start_y + 17), self.PASSED, font = self.badge_font, fill = self.BLACK)
+ self.draw.text((self.__from_right(badge_width - 35), start_y + 17), self.PASSED, font = self.badge_font, fill = self.BLACK)
def __render_project_name(self, row):
index = row[0]
@hanneskaeufler
hanneskaeufler / backstop_setup_usage.sh
Last active April 8, 2018 10:20
Using BackstopJS
# Install backstopjs locally
yarn add backstopjs
# Setup folders, configuration etc.
./node_modules/.bin/backstopjs init
# Edit backstop.json to configure the viewports you want to test on.
# I use the following:
# "viewports": [
# {
@hanneskaeufler
hanneskaeufler / lucky_visual_testing.sh
Created April 8, 2018 10:36
Setup DB for visual testing
# Create and migrate a new database just for visual regression testing
LUCKY_ENV=visual_test lucky db.create && lucky db.migrate
# Add one sample post
open http://localhost:5000/posts/new
# Run the local server with that one sample post
LUCKY_ENV=visual_test lucky dev
@hanneskaeufler
hanneskaeufler / bitbucket-pipelines.yml
Created May 23, 2018 19:05
PitBuddy App Bitbucket Pipelines Configuration
pipelines:
default:
- step:
name: "Run visual regression tests"
image: backstopjs/backstopjs:v3.2.15
script:
- backstop test
- step:
name: "Deploy to website"
image: fgch/alpine-gitftp
@hanneskaeufler
hanneskaeufler / 100_percent_code_coverage.cr
Last active October 20, 2018 15:54
100% code coverage but not really uncovered
# valid.cr
def valid?
true
end
# valid_spec.cr
require "./valid"
require "spec"
describe "valid?" do