Skip to content

Instantly share code, notes, and snippets.

View ziyan-junaideen's full-sized avatar
👋
How you doing?

Ziyan Junaideen ziyan-junaideen

👋
How you doing?
View GitHub Profile
@SanderTheDragon
SanderTheDragon / postman-deb.sh
Last active April 3, 2024 05:30
A shellscript to create a Postman .deb file, for simple installation on Debian-based Linux distro's. Also creates a .desktop file.
#!/bin/sh
# SPDX-FileCopyrightText: 2017-2022 SanderTheDragon <sanderthedragon@zoho.com>
#
# SPDX-License-Identifier: MIT
curlExists=$(command -v curl)
echo "Testing Postman version"
@yosukehasumi
yosukehasumi / readme.md
Last active October 22, 2021 15:12
DigitalOcean Rails/Ubuntu/NGINX (16.04) Setup

DigitalOcean Rails/Ubuntu/NGINX (16.04) Setup

  1. Setup
  2. Swapfile
  3. NGINX
  4. ElasticSearch
  5. RVM
  6. Rails
  7. Postgres
  8. Capistrano
@fran-worley
fran-worley / error_messages.yml
Last active April 18, 2021 08:25
Reform/ Dry-V validation examples
en:
errors:
rules:
title:
filled?: "can't be blank"
first_name:
filled?: "can't be blank"
last_name:
filled?: "can't be blank"
email:
@devonzuegel
devonzuegel / .pryrc
Last active August 7, 2023 06:16
My .pryrc file
# === EDITOR ===
Pry.editor = 'vi'
require 'awesome_print'
# == Pry-Nav - Using pry as a debugger ==
Pry.commands.alias_command 'c', 'continue' rescue nil
Pry.commands.alias_command 's', 'step' rescue nil
Pry.commands.alias_command 'n', 'next' rescue nil
# === CUSTOM PROMPT ===
@auscaster
auscaster / UsersController.rb
Created May 11, 2014 08:15
UsersController using Devise and CanCan
# Used in http://sourcey.com/rails-4-omniauth-using-devise-with-twitter-facebook-and-linkedin
# This class also uses CanCan to protect user object access
class UsersController < ApplicationController
before_action :set_user, only: [:show, :edit, :update, :destroy]
# GET /users
# GET /users.json
def index
@users = User.all
end
@dvliman
dvliman / gist:10402435
Created April 10, 2014 17:02
ruby $ global variable
$: (Dollar Colon) is basically a shorthand version of $LOAD_PATH. $: contains an array of paths that your script will search through when using require.
$0 (Dollar Zero) contains the name of the ruby program being run. This is typically the script name.
$* (Dollar Splat) is basically shorthand for ARGV. $* contains the command line arguments that were passed to the script.
$? (Dollar Question Mark) returns the exit status of the last child process to finish.
$$ (Dollar Dollar) returns the process number of the program currently being ran.
$~ (Dollar Tilde) contains the MatchData from the previous successful pattern match.
$1, $2, $3, $4 etc represent the content of the previous successful pattern match.
$& (Dollar Ampersand) contains the matched string from the previous successful pattern match.
$+ (Dollar Plus) contains the last match from the previous successful pattern match.
$` (Dollar Backtick) contains the string before the actual matched string of the previous successful pattern match.
@ismyrnow
ismyrnow / google-analytics-amd.js
Last active March 14, 2022 21:32
Google Analytics AMD Module
define(function (require) {
var module;
// Setup temporary Google Analytics objects.
window.GoogleAnalyticsObject = "ga";
window.ga = function () { (window.ga.q = window.ga.q || []).push(arguments); };
window.ga.l = 1 * new Date();
// Immediately add a pageview event to the queue.
@lulalala
lulalala / banner.rb
Last active January 14, 2019 12:58 — forked from matheusvetor/banner.rb
Carrierwave image model validation on image dimensions/height/width.
class Banner < ActiveRecord::Base
attr_accessor :image_width, :image_height
mount_uploader :image, ImageUploader
validate :check_dimensions, :on => :create
def check_dimensions
if !image_cache.nil? && (image.width < 300 || image.height < 300)
errors.add :image, "Dimension too small."
end
end
@smithcommajoseph
smithcommajoseph / constantize.js
Last active March 12, 2021 02:43
A JS implementation of Ruby's constantize
// A basic example of how Ruby's constantize _could_ work in JS
// See https://apidock.com/rails/String/constantize
function constantize (str) {
if (typeof str !== 'string') {
throw new TypeError('must pass in type of string');
}
if (str.match(/\W|\d/)) {
throw new SyntaxError('must pass in a valid Javascript name');
}
@rjz
rjz / cs-jq-plugin-template.coffee
Created September 3, 2012 17:01
Coffeescript jQuery Plugin Class Template
# A class-based template for jQuery plugins in Coffeescript
#
# $('.target').myPlugin({ paramA: 'not-foo' });
# $('.target').myPlugin('myMethod', 'Hello, world');
#
# Check out Alan Hogan's original jQuery plugin template:
# https://github.com/alanhogan/Coffeescript-jQuery-Plugin-Template
#
(($, window) ->