Skip to content

Instantly share code, notes, and snippets.

View jamesguan's full-sized avatar
🏠
Working from home

James Guan jamesguan

🏠
Working from home
  • San Francisco, California
View GitHub Profile
class FulfillmentInstructions(Service):
name = 'gg.order.svc.fulfillment_instructions'
class SimpleIO:
input_required = (AsIs('order_id'), )
input_optional = (AsIs('fulfillment_id'), )
def handle_POST(self):
self.logger.info("POST")
===PCM DTC P0306:00-28===
Code: P0306 - cylinder 6 misfire detected
Status:
- Previously Set DTC - Not Present at Time of Request
- Malfunction Indicator Lamp is Off for this DTC
Module: Powertrain Control Module
===END PCM DTC P0306:00-28===
@jamesguan
jamesguan / python-date-format-to-javascript.js
Last active January 16, 2024 21:36
Function to convert python datetime format to javascript datetime format
// ES6 syntax is used.
/* Key: Python format
* Value: Javascript format
*/
const pyToJSDateFormats = Object.freeze({
'%A': 'dddd', //Weekday as locale’s full name: (In English: Sunday, .., Saturday)(Auf Deutsch: Sonntag, .., Samstag)
'%a': 'ddd', //Weekday abbreivated: (In English: Sun, .., Sat)(Auf Deutsch: So, .., Sa)
'%B': 'MMMM', //Month name: (In English: January, .., December)(Auf Deutsch: Januar, .., Dezember)
'%b': 'MMM', //Month name abbreviated: (In English: Jan, .., Dec)(Auf Deutsch: Jan, .., Dez)
// Requires jquery
/*
* Price Input Validator binds to classes price_validator
* It changes the input based on the oninput event.
* Usage: Bind to parent that will contain the dynamically generated
* price_validator classes. Works for input fields. Possibly text fields and
* text areas as well. Will work with copy and pasted inputs.
*/
$(function() {
#excell formats:
default_format = easyxf()
float_format = easyxf(num_format_str='#,##0.00')
int_format = easyxf(num_format_str='#,##0')
If you manually edit the repository and use credentials different from the one in the deployment services directory,
it might blow away the credentials that jenkins uses to build on the repository.
Also, using sudo or root will change permissions on the directory so permissions must be restored to the proper account.
If so follow one of these steps:
1.Readd the credentials to the repository or jenkins build scripts
2. (Bad because it shows password):
git config remote.origin.url "https://{username}:{password}@github.com/{username}/project.git"
@jamesguan
jamesguan / destroybootstrapmodalproperly.js
Created January 8, 2018 14:35
How to destroy bootstrap modal propertly
// Do this when running into issues such as duplicate form data
$('#modalID').on('hidden.bs.modal', function () {
$(this).data('bs.modal', null).remove();
});
https://zanon.io/posts/nosql-injection-in-mongodb
https://blog.websecurify.com/2014/08/hacking-nodejs-and-mongodb.html
Scenarios:
Git:
Conjure:
1. To query, use: Order.objects._collection.find()
2. Finding if an array field contains an element:
Ex: Order.objects._collection.find({'array_thing.0': {'$exists': True})
3. Finding values greater than or less than a certain range (This will also avoid pre-commmit hooks from trigger duplicate key use)
Ex: '$and': [{'field_i_want': {'$gt': min_val}}, {'field_i_want': {'$lt': max_val}}]}, projection)
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\Background\shell\PowerShellAsAdmin]
@="Open PowerShell window here as administrator"
"Extended"=""
"HasLUAShield"=""
"Icon"="powershell.exe"
[HKEY_CLASSES_ROOT\Directory\Background\shell\PowerShellAsAdmin\command]
@="C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\powershell.exe -windowstyle hidden -Command \"Start-Process powershell -ArgumentList '-NoExit', '-Command cd %V' -Verb runAs\""