Skip to content

Instantly share code, notes, and snippets.

View marat-chardymov's full-sized avatar

Marat Chardymov marat-chardymov

View GitHub Profile
@jonathanconway
jonathanconway / docker-nuke
Last active June 16, 2022 19:59
Nuke all docker images and containers ☢️
#!/bin/bash
docker rm --force $(docker ps --all -q)
docker rmi --force $(docker images --all -q)
@skratchdot
skratchdot / create_stub_example.js
Created January 7, 2016 17:58
An example of how I was using a sinon stub to mock creating uuids
import uuid from 'node-uuid';
import sinon from 'sinon';
const mockId = '00000000-0000-0000-0000-000000000000';
describe('some test', () => {
it('does something', () => {
// create stub
sinon.stub(uuid, 'v4', function () {
return mockId;
});
@icirellik
icirellik / test.js
Created August 25, 2015 20:02
Pass data between beforeEach, afterEach and it in mocha tests.
var expect = require('expect');
describe.only('Sample', function () {
beforeEach(function () {
this.currentTest.value = 'Winning!';
});
it('Uses current test data', function () {
expect(this.test.value).to.equal('Winning!');
@dmilisic
dmilisic / active_record_enum_with_rails_admin.rb
Last active January 21, 2022 10:50
Initializer for handling ActiveRecord (4.1+) enums by RailsAdmin (0.6.2)
module ActiveRecord
module RailsAdminEnum
def enum(definitions)
super
definitions.each do |name, values|
define_method("#{ name }_enum") { self.class.send(name.to_s.pluralize).to_a }
define_method("#{ name }=") do |value|
if value.kind_of?(String) and value.to_i.to_s == value
@lfender6445
lfender6445 / gist:9919357
Last active September 2, 2024 03:43
Pry Cheat Sheet

Pry Cheat Sheet

Command Line

  • pry -r ./config/app_init_file.rb - load your app into a pry session (look at the file loaded by config.ru)
  • pry -r ./config/environment.rb - load your rails into a pry session

Debugger

@manuelmeurer
manuelmeurer / controller.rb
Last active November 15, 2016 16:06
Render dynamic CSS
class Display::WidgetsController < ApplicationController
def show
scss = render_to_string('show', locals: { foo: bar }, formats: :scss)
@css = Sass::Engine.new(scss, Compass.sass_engine_options.merge(syntax: :scss)).render
end
end
@rponte
rponte / applicationContext-persistence.xml
Created February 23, 2012 15:06
configuring Hibernate (JPA) ImprovedNamingStrategy which prefers embedded underscores to mixed case names
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="showSql" value="true" />
<property name="databasePlatform" value="${hibernate.databasePlatform}" />
</bean>
</property>
<property name="jpaProperties">
@zhengjia
zhengjia / capybara cheat sheet
Created June 7, 2010 01:35
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')