Skip to content

Instantly share code, notes, and snippets.

@nthock
nthock / keybase.md
Created June 2, 2020 04:44
keybase

Keybase proof

I hereby claim:

  • I am nthock on github.
  • I am nthock (https://keybase.io/nthock) on keybase.
  • I have a public key ASBTUMREc2wHG3s1GwHPKS5aG08FRwIfUgASyjIuUiht1go

To claim this, I am signing this object:

@nthock
nthock / AdminListComposer.spec.js
Last active April 25, 2018 07:08
React Boilerplate Gist
import React from "react";
import { mount } from "enzyme";
import renderer from "react-test-renderer";
import { setMockGraphQLProps, setMockGraphQLErrorProps } from "react-apollo";
import AdminListComposer from "../../../bundles/admin/composers/AdminListComposer";
const EmptyComponent = () => null;
const EnhancedComponent = AdminListComposer(props => (
<EmptyComponent {...props} />
));
@nthock
nthock / VersionNumber.js
Created April 24, 2018 14:29
Example of Mocking GraphQL Apollo
import React from "react";
import { graphql } from "react-apollo";
import { compose } from "recompose";
import { someQuery } from "SOMEPATH";
export const VersionNumber = ({ data: { config: { version } } }) => (
<div>
v{version}
</div>
@nthock
nthock / Dashboard.js
Created April 1, 2018 15:20
Simple setup of Rails API + React Frontend
import React from 'react';
import request from 'superagent';
import { compose, withState, withHandlers, lifecycle } from 'recompose';
const Dashboard = (props) => {
const { winnie, onSubmit, users } = props;
return (
<div>
<div>This is Dashboard - {winnie}</div>
<button onClick={() => onSubmit()}>Click Me</button>
desc "Create fake order to test actual ticket"
task populate_fake_order: :environment do
event = Event.first
event_seat_category = event.event_seat_categories.first
event_seat = event.event_seats.first
# Update Event Seat
event_seat.update(event_seat_category_id: event_seat_category.id,
section: "200",
row: "A",
money_fields = $('input[data-role=money]');
money_fields.autoNumeric('init', {
aSep: ',',
aDec: '.',
mDec: '0',
vMin: '0',
vMax: '9999999999'
});
def status_validations
rules = THE_RULES[self.event.status]
unless rules.nil?
errors.add(:status, 'Invalid update of Event Seat due to the current event status.') unless rules[status_was.to_sym].include? status
end
end
@nthock
nthock / PdfController.rb
Created October 12, 2017 14:32
GSub using Regex
class PdfController < ApplicationController
def export
location = "Singapore"
event = "Jay Chou World Tour Concert Singapore 2017"
raw_svg = '<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="300" height="150" viewBox="0 0 300 150" xml:space="preserve">
<desc>Created with Fabric.js 1.7.19</desc>
@nthock
nthock / create_todo_list.rb
Created August 27, 2017 09:46
Example Features Test (The first test you should write)
feature "create a todo list" do
it "should create one todo list" do
visit "/todo_lists/new"
expect(page).to have_http_status(:success)
expect(page).to have_text("Create New Todo List")
fill_in "Title", with: "School Work"
fill_in "Description", with: "List of projects / readings to do"
click_button "Create Todo List"
@nthock
nthock / html_demo.html
Created July 21, 2017 04:32
HTML Demo
<!DOCTYPE html>
<html>
<head>
<title>HTML, CSS and JavaScript Demo</title>
</head>
<body>
<h1>HTML, CSS and JavaScript Demo</h1>
<!-- Paragraph and anchor tag section -->
<div>