Skip to content

Instantly share code, notes, and snippets.

View weitzman's full-sized avatar

Moshe Weitzman weitzman

View GitHub Profile
@dhh
dhh / linux-setup.sh
Last active November 15, 2024 19:55
linux-setup.sh
# THIS LINUX SETUP SCRIPT HAS MORPHED INTO A WHOLE PROJECT: HTTPS://OMAKUB.ORG
# PLEASE CHECKOUT THAT PROJECT INSTEAD OF THIS OUTDATED SETUP SCRIPT.
#
#
# Libraries and infrastructure
sudo apt update -y
sudo apt install -y \
docker.io docker-buildx \
build-essential pkg-config autoconf bison rustc cargo clang \
<?php
# put this file in ~/.config/psysh/
if (class_exists('Drupal')) {
foreach (\Drupal::entityTypeManager()->getDefinitions() as $definition) {
$class = $definition->getClass();
$parts = explode('\\', $class);
class_alias($class, end($parts));
}
}
@algal
algal / websitescreenshot.md
Last active August 11, 2024 18:37
Taking website screenshots, in Chrome or Safari, including simulating iPhones

Taking website screenshots

These are instructions for taking screenshots of an entire webpage, not just the part of the webpage visible in the browser.

Website Screenshots in Safari

This requires Safari 11.3, which comes on macOS 10.3.4.

  1. Open the website in Safari
  2. If needed, go Safari > Preferences > Advanced > Show Develop Menu in Menu Bar
@shrynx
shrynx / macOSOpenURLInChrome.js
Created March 8, 2018 11:23
open url in chrome on macOS and reuse already open tab if possible.
#!/usr/bin/env osascript -l JavaScript
const Chrome = Application('Chrome');
// although there is ES6 support , but "run" function
// can't use fat arrow functions.
// https://github.com/JXA-Cookbook/JXA-Cookbook/wiki/ES6-Features-in-JXA#arrow-functions
function run(args) {
const url = args[0];
const tabData = findTabForUrl(url);
@MichalZalecki
MichalZalecki / Dockerfile
Last active January 25, 2023 23:23
Install oh-my-zsh in Docker
RUN ["apt-get", "update"]
RUN ["apt-get", "install", "-y", "zsh"]
RUN wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | zsh || true
# docker exec -it my-app-container /bin/zsh
# How to force disable interface translation by overriding the locale lookup service to not be added to the translation manager
# settings.local.php:
$settings['container_yamls'][] = DRUPAL_ROOT . '/sites/default/services.local.yml';
# services.local.yml (add this file to .gitignore):
services:
string_translator.locale.lookup:
class: Drupal\locale\LocaleTranslation
# Autogenerated input type of AddComment
input AddCommentInput {
# A unique identifier for the client performing the mutation.
clientMutationId: String
# The Node ID of the subject to modify.
subjectId: ID!
# The contents of the comment.
body: String!
@weaverryan
weaverryan / README.md
Created August 4, 2016 21:04
Testing Questions with my Answers (fwtw)

From a user on KnpUniversity.com:

How do you manage testing form validation situations?

For form validation situations, I typically only write 2 scenarios (or sometimes just 1): one that checks that if I submit invalid data, that I see a validation error (I don’t, however assert that all of the validation errors are there – just that the form has some validation errors). Second, I write a scenario that checks a successful form submit.

For me, creating many scenarios to submit a form and check for the different validation errors is over-kill. 99% of the time, adding validation – in Symfony for example – is just one line of code. If we write a scenario for each, we now have one scenario just to test whether or not one line of code is present. For this, I check the validation errors manually – just to make sure I didn’t forget them. I’m not worried about a regression, because it’s highly unlikely that we’ll accidentally remove a line of validation and introduce a bug.

However

@magickatt
magickatt / SomethingContext.php
Last active October 25, 2016 15:39
Save screenshot of a failed Behat step
<?php
/**
* @AfterStep
*/
public function takeScreenshotAfterFailedStep($event)
{
if ($event->getTestResult()->getResultCode() === \Behat\Testwork\Tester\Result\TestResult::FAILED) {
$driver = $this->getSession()->getDriver();
if ($driver instanceof \Behat\Mink\Driver\Selenium2Driver) {
@jaymcgavren
jaymcgavren / monkey_cherry_picking.md
Last active March 27, 2023 11:41
"Monkey cherry-picking": Freehand patching via Git and the clipboard...

I run a diff of my current branch versus a different one that has some stuff I want:

$ git diff HEAD subscribers_decorator | cat
diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb
index 245393c..6a1639a 100644
...

Big 'ol list of stuff I don't want...

Followed by a portion that I do want... Which I manually copy.