Skip to content

Instantly share code, notes, and snippets.

View nhnam's full-sized avatar
💭
Play hard, work harder

ナ-ム Nguyen nhnam

💭
Play hard, work harder
View GitHub Profile
import MAFNavigationRegistry
public struct UserModule {
public static var userModuleRegistry: MAFModuleRegistry = MAFModuleRegistry(
module: "user",
stacks: [
MAFNavigationComponent(
screen: "main",
component: UserRootViewController.self
),
// Save item if not exist
let storingResult = UserDefaults.safe.setValue("123456", forKey: "selected_number", forceOverride: {
return false
})
// return StoringResult.success
let role = Role.admin
// Force override set to true due a condition
let storingResult = UserDefaults.safe.setValue("123456", forKey: "selected_number", forceOverride: {
return role == .admin
})
// return StoringResult.overrided
@nhnam
nhnam / ATM.js
Created December 13, 2020 13:21
/* ATM */
/**
Input the amount, return the notes
Asume that there are types: 1000, 100, 50, 10, 5, 2, 1
Example: 1200 USD:
**/
let result = {};
let notes = [100, 50, 10, 5, 2, 1];
let index = 0;
/*Roman to Decimal*/
/**
Algorithm
Loop through each character in the string containing the roman numerals.
Compare the value of the current roman symbol with the value of the roman symbol to its right.
If the current value is greater than or equal to the value of the symbol to the right, add the current symbol’s value to the total.
If the current value is smaller than the value of the symbol to the right, subtract the current symbol’s value from the total.
**/
const romanCode = {
1000:'M',
900: 'CM',
500:'D',
400: 'CD',
100: 'C',
90: 'XC',
50: 'L',
40: 'XL',
@nhnam
nhnam / embedded-file-viewer.md
Created July 23, 2020 10:48 — forked from tzmartin/embedded-file-viewer.md
Embedded File Viewer: Google Drive, OneDrive

Office Web Apps Viewer

('.ppt' '.pptx' '.doc', '.docx', '.xls', '.xlsx')

http://view.officeapps.live.com/op/view.aspx?src=[OFFICE_FILE_URL]

<iframe src='https://view.officeapps.live.com/op/embed.aspx?src=[OFFICE_FILE_URL]' width='px' height='px' frameborder='0'>
</iframe>

OneDrive Embed Links

function* pspFlow(){
yield 'LoginScreen';
yield 'ActivationScreen';
yield 'ActivationSubmittedScren';
}
function* p360pFlow(){
yield 'LoginScreen';
yield 'GeneralDeviceCheckScreen';
yield 'BackCameraCheckScreen';
const STATUS_RELEVANT_TEXT = {
ACTIVATION_PROCESSING: 'Activation Processing',
ACTIVATION_FAILED: 'Activation Failed',
ACTIVATION_APPROVED: 'Activation Approved',
ACTIVATION_REJECTED: 'Activation Rejected',
ACTIVATION_REJECTED_TIP:
'Activation rejected due to “broken screen”. You may only purchase a plan if your phone is in good condition. We will refund the premium paid to your original payment method within 3 working days.',
ACTIVATION_FAILED_TIP:
'Activation failed because “photo is blurry”. Please re-submit the activation to activate your plan.',
RE_START_ACTIVATION: 'Re-start Activation',
const activationStatus = {
processing: 'processing',
rejected: 'rejected',
approved: 'approved',
expired: 'expired'
}
const paymentStatus = {
pending: 'pending',
processing: 'processing',