Skip to content

Instantly share code, notes, and snippets.

View matmar10's full-sized avatar

Matthew Joseph Martin matmar10

View GitHub Profile
@matmar10
matmar10 / switch-case-with-object-ref.ts
Created November 15, 2022 05:00
Demonstrate improper use of switch with object reference
import { Prisma } from '@prisma/client';
function testPrismaDecimal(decimalInstance: Prisma.Decimal) {
console.log('Testing: ', decimalInstance);
switch (decimalInstance) {
case new Prisma.Decimal(0):
console.log('It is: 0');
break;
case new Prisma.Decimal(1):
console.log('It is: 1');
@matmar10
matmar10 / ChildClass.php
Created October 5, 2021 14:29
Test run-time set of property specified in child class
<?php
class ChildClass extends ParentClass {
protected $json;
public function __construct() {
parent::__construct();
}
@matmar10
matmar10 / Common-Currency.json
Last active August 9, 2020 11:31 — forked from ksafranski/Common-Currency.json
Common Currency Codes in JSON
{
"USD": {
"symbol": "$",
"name": "US Dollar",
"symbol_native": "$",
"decimal_digits": 2,
"rounding": 0,
"code": "USD",
"name_plural": "US dollars"
@matmar10
matmar10 / js-class-private-members-example.js
Last active June 16, 2020 07:38
Demonstrates private members using closure scope
const Person = (function() {
// currentName cannot be modified externaly
let currentName;
function isGoodName() {
return !!currentName.match(/Snehanshu/);
}
class Person {
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<script src="https://code.jquery.com/jquery-3.1.0.js"></script>
<link href="https://code.jquery.com/qunit/qunit-git.css" rel="stylesheet" type="text/css" />
<script src="https://code.jquery.com/qunit/qunit-git.js"></script>
<script src="https://blossom-sample-api.herokuapp.com/qunit-test-suite.js"></script>
@matmar10
matmar10 / Gruntfile.js
Created May 15, 2017 09:15
Update embark.json with bower.json dependencies
const wiredep = require('wiredep');
module.exports = function initGrunt(grunt) {
grunt.initConfig({
embark: grunt.file.readJSON('embark.json'),
});
grunt.registerTask('addDeps', 'Adds JS dependencies to embark config', function () {
const deps = wiredep();
@matmar10
matmar10 / main.c
Last active October 25, 2015 22:22
#include <pebble.h>
#include <PDUtils.h>
#define KEY_DATE_YEAR 0
#define KEY_DATE_MONTH 1
#define KEY_DATE_DAY 2
#define KEY_FAJR_HOUR 3
#define KEY_FAJR_MINUTE 4
#define KEY_SHUROOQ_HOUR 5
#define KEY_SHUROOQ_MINUTE 6
@matmar10
matmar10 / gist:a2fc0ecc94e2840b9f9a
Created June 3, 2015 06:40
Sequelize issue #3433 partial fix
diff --git a/lib/instance.js b/lib/instance.js
index 5668513..688f286 100644
--- a/lib/instance.js
+++ b/lib/instance.js
@@ -737,6 +737,7 @@ module.exports = (function() {
*
* @see {Model#find}
* @param {Object} [options] Options that are passed on to `Model.find`
+ * @param {Array} [options.include] List of joined models to include. If no include option is provided, uses the include option provided to instance in previous `Model.find`
@matmar10
matmar10 / gist:f0ff6a339e580d205dc8
Created May 3, 2015 04:54
Create coinbase multi-sig wallet
var Client = require('coinbase').Client;
var client = new Client({
'apiKey': 'your-coinbase-sandbox-api-key',
'apiSecret': 'your-coinbase-sandbox-api-secret',
'baseApiUri': 'https://api.sandbox.coinbase.com/v1/',
});
var sampleData = {
"name": "Multisig Wallet",
"type": "multisig",
@matmar10
matmar10 / example-config.yml
Created April 1, 2015 12:49
Wrong way to iterate over hash in ansible
---
good_things:
coffee: because you can sleep when you are dead
food: because you need calories to live
ansible: because devops