Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Jamal rubypirate

🏠
Working from home
View GitHub Profile
View nested-multi-level-rails-react.rb
###
Can't share whole app, but this is a snippet of recent work I did using Rails 6 and React to render nested categories in the CMS to allow users grasp hierarchy easily.
###
class Category < ApplicationRecord
resourcify
has_ancestry
before_save :default_values
attribute :depth
View gist:4e2789b86873ddb94ecf29e64caba2f7
var todoList = {
todos: [],
addTodo: function(todoText) {
this.todos.push({
todoText: todoText,
completed: false
});
},
changeTodo: function(position, todoText) {
this.todos[position].todoText = todoText;
View google_core.rb
module GoogleCore
ICAL = 0
SYNC_TWO_WAYS = 0
SYNC_TO_GCAL = 1
SYNC_TO_BB = 2
### Google Calendar Syncing Options
IGNORE_CHANGES = 0
View refund.rb
class Refund
def submit
#raise self.journey.end_time.strftime("%h").inspect
session = if ARGV[0] != 'phantomjs'
Capybara::Session.new(:selenium)
else
require 'capybara/poltergeist'
Capybara::Session.new(:poltergeist)
end
View ews_core.rb
module EwsCore
def ews_watch
if params["Envelope"]
cal_ids = []
subscription_id = find_all_values_for(params, 'SubscriptionId').first
if subscription_id
View sales_cloud_responses.xml
<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:typ='http://xmlns.oracle.com/apps/crmCommon/salesParties/contactService/types/' xmlns:con='http://xmlns.oracle.com/apps/crmCommon/salesParties/contactService/' xmlns:com='http://xmlns.oracle.com/apps/crmCommon/salesParties/commonService/'>
<soapenv:Header/>
<soapenv:Body>
<typ:createContact>
<typ:contact>
<!-- Owner Party ID is account -->
<con:OwnerPartyId>300000000740925</con:OwnerPartyId>
<con:FirstName>alpha</con:FirstName>
<con:LastName>London</con:LastName>
<con:EmailAddress>alpha@bookingbug.com</con:EmailAddress>
View cal.rb
# -*- encoding : utf-8 -*-
require 'ri_cal'
require 'icalendar'
require 'google/api_client'
module Icalendar
# add summary to freebusy - because Google use it!
class Freebusy < Component
ical_property :summary
end
View gist:e4f30b1d99184e1cb968
App 10453 stdout:
App 10966 stdout:
[ 2015-03-11 16:28:26.6206 9022/b552fb40 Pool2/SmartSpawner.h:298 ]: Preloader for /home/deploy/platform/current started on PID 10966, listening on unix:/tmp/passenger.1.0.9014/generation-0/backends/preloader.pib030
App 11073 stdout:
App 11225 stdout:
App 11424 stdout:
App 11464 stdout:
[ 2015-03-11 16:29:50.8651 9022/b56bcb40 Pool2/SmartSpawner.h:298 ]: Preloader for /home/deploy/platform/current started on PID 11464, listening on unix:/tmp/passenger.1.0.9014/generation-0/backends/preloader.1o4u0ib
App 11575 stdout:
App 11586 stdout:
View nginx conf
user www-data;
worker_processes 4;
pid /run/nginx.pid;
events {
worker_connections 768;
# multi_accept on;
}
http {
View euro_millions.rb
# this code helps you generate random numbers for euro millions lottery
# how to run, ruby euro_millions.rb
@numbers = []
@stars_numbers = []
cards_num = 100
cards_num.times.each_with_index do |i|
rnum = rand(1..50)
stars_number = rand(1..11)
if @stars_numbers.count < 2