Skip to content

Instantly share code, notes, and snippets.

View suciuvlad's full-sized avatar

Vlad Suciu suciuvlad

View GitHub Profile
@suciuvlad
suciuvlad / zsh
Created April 18, 2012 14:56 — forked from tonyjcamp/zsh
zsh Theme
# https://github.com/blinks zsh theme
function _prompt_char() {
if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then
echo "%{%F{blue}%}±%{%f%k%b%}"
else
echo ' '
fi
}
@suciuvlad
suciuvlad / deferred-img.js
Created November 9, 2012 11:04 — forked from fcalderan/deferred-img.js
Image loader / preloader achieved by deferred objects in jQuery 1.6
/**
* For a current project I need to wait to execute a code until some images have been loaded.
* Beside, I also need to execute a callback (in my specific code I want to show the image
* with a fade-in effect) every time a single image has been loaded.
*
* So basically I used two deferred objects: the nested one which is resolved for a single
* image successfull load event (or when image has been discarded) and the outside one,
* which is resolved when all deferred objects on single images have been resolved or rejected.
*
* This snippet also takes care all frequent issues when trying to load an image (excessive
@suciuvlad
suciuvlad / with_retries.rb
Created November 15, 2012 11:24 — forked from cainlevy/with_retries.rb
with_retries{} helper to easily catch and retry exceptions in Ruby
module Retriable
# This will catch any exception and retry twice (three tries total):
# with_retries { ... }
#
# This will catch any exception and retry four times (five tries total):
# with_retries(:limit => 5) { ... }
#
# This will catch a specific exception and retry once (two tries total):
# with_retries(Some::Error, :limit => 2) { ... }
#
# An abstract base class used to create simple serializers
# for ActiveRecord objects
class BaseSerializer
include Rails.application.routes.url_helpers
attr_reader :serialized_object
def initialize(serialized_object)
@serialized_object = serialized_object
end
desc 'Benchmark funds_raised methods'
ITERATIONS = 1000
task benchmark_sql: :environment do
campaign = Campaign.last
Benchmark.bm do |bm|
bm.report('sql') do
ITERATIONS.times do
@suciuvlad
suciuvlad / checklist.md
Created October 29, 2015 17:45 — forked from mzabriskie/checklist.md
Release Process
  1. npm test
  2. npm run build
  3. Update package.json & bower.json version
  4. Update Changelog.md
  5. git commit -am"Releasing x.x.x"
  6. git push
  7. git tag -a vx.x.x -m"version x.x.x"
  8. git push origin --tags
  9. npm publish ./
@suciuvlad
suciuvlad / Enhance.js
Created July 2, 2016 16:20 — forked from sebmarkbage/Enhance.js
Higher-order Components
import { Component } from "React";
export var Enhance = ComposedComponent => class extends Component {
constructor() {
this.state = { data: null };
}
componentDidMount() {
this.setState({ data: 'Hello' });
}
render() {
@suciuvlad
suciuvlad / cloud-run.yml
Created February 21, 2022 16:28 — forked from jmaicaaan/cloud-run.yml
[Tutorial] Setting up cloud-run.yml for Github Actions
name: nextjs-cloud-run
on:
push:
branches:
- master
- main
env:
CLOUD_RUN_PROJECT_ID: ${{ secrets.CLOUD_RUN_PROJECT_NAME }}
@suciuvlad
suciuvlad / rules for good testing.md
Created March 7, 2022 11:24 — forked from Integralist/rules for good testing.md
Sandi Metz advice for writing tests

Rules for good testing

Look at the following image...

...it shows an object being tested.

You can't see inside the object. All you can do is send it messages. This is an important point to make because we should be "testing the interface, and NOT the implementation" - doing so will allow us to change the implementation without causing our tests to break.

@suciuvlad
suciuvlad / 1_simple.go
Created July 8, 2022 06:26 — forked from sosedoff/1_simple.go
Golang Custom Struct Tags Example
package main
import (
"fmt"
"reflect"
)
// Name of the struct tag used in examples
const tagName = "validate"