Skip to content

Instantly share code, notes, and snippets.

@p9436
p9436 / facebook.feature
Created November 10, 2011 08:19
Rails, Device, OmniAuth and Cucumber
# features/facebook.feature
Feature: Sign Up
In order to sign up
As a user
Should be able to sign up with facebook
@omniauth_test
Scenario: User sign in with facebook
Given I am not logged in
@p9436
p9436 / index.html
Created April 10, 2015 09:56
Phaser player sandbox 20x20 Phaser player sandbox 20x20 // source http://jsbin.com/toneni
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="Phaser player sandbox 20x20" />
<script src="http://cdn.jsdelivr.net/phaser/2.2.2/phaser.min.js"></script>
<meta charset="utf-8">
<title>Phaser player sandbox 20x20</title>
</head>
<body>
@p9436
p9436 / gist:15bf9045ecf6c2787c9d
Created June 15, 2015 13:51
Certificate for apn_sender
$ openssl x509 -in cert.cer -inform DER -outform PEM -out cert.pem
$ openssl pkcs12 -in key.p12 -out key.pem -nodes
test:
$ openssl s_client -connect gateway.sandbox.push.apple.com:2195 -cert cert.pem -key key.pem
and final step:
$ cat cert.pem key.pem > apn-development.pem
<?php
// стандарт КМУ2010 http://zakon5.rada.gov.ua/laws/show/55-2010-%D0%BF
function cyr2lat($string) {
$ukr = ['Є', 'Ї', 'Й', 'Ю', 'Я', 'є', 'ї', 'й', 'ю', 'я' ];
$lat = ['Ye', 'Yi', 'Y', 'Yu', 'Ya', 'ye', 'yi', 'y', 'yu', 'ya' ];
for ($i=0,$ic=sizeof($ukr); $i < $ic; $i++) {
$string = preg_replace("/(^|\s)".$ukr[$i]."/u", '$1'.$lat[$i], $string);
}
@p9436
p9436 / migrations2sql.rake
Last active February 8, 2017 13:46
Generate SQL files from rails migrations
namespace :db do
task migrations2sql: :environment do |task|
SQL_FILES_DIR = Rails.root.join('tmp', 'sql')
FileUtils.rm_rf(SQL_FILES_DIR, secure: true)
Dir.mkdir(SQL_FILES_DIR) unless File.exists?(SQL_FILES_DIR)
TMP_FILE = Tempfile.new('migrations2sql')
@p9436
p9436 / event_log.rb
Last active February 9, 2017 14:54
EventLogger
# concerns/event_log.rb
module EventLog
extend ActiveSupport::Concern
included do
has_many :logs, as: :logable, class_name: 'EventLogger'
attr_accessor :current_user
after_create :event_log_create
after_update :event_log_update
@p9436
p9436 / jbuilder.rb
Created August 11, 2017 07:06
show execution time of grape jbuilder
# gems/grape-jbuilder-0.2.0/lib/grape/formatter/jbuilder.rb
module Grape
module Formatter
class Jbuilder
def call
return Grape::Formatter::Json.call(object, env) unless template?
start_time = Time.now
r = Grape::Jbuilder::Renderer.new(env['api.tilt.root'], template).
FROM ruby:2.3.1-alpine
MAINTAINER Vadym Lukavyi <vadym@masterofcode.com>
ENV BUILD_PACKAGES="curl-dev ruby-dev build-base" \
DEV_PACKAGES="zlib-dev libxml2-dev libxslt-dev tzdata yaml-dev postgresql-dev" \
RUBY_PACKAGES="ruby-json yaml nodejs"
RUN apk update && \
apk upgrade && \
apk add --update\
@p9436
p9436 / httprequests.http
Last active August 1, 2024 07:27
httprequests.http for Next.js + Auth.js
### An example of HTTP requests for Next.js + Next-auth.js (Auth.js) with credentials login
### for testing your API endpoints
### Variables
@host = http://localhost:3000
@callback_url = http://localhost:3000/login
@admin_email = admin@example.com
@admin_password = secretpassword
### 1. GET CSRF token