Skip to content

Instantly share code, notes, and snippets.

View hieuphq's full-sized avatar

Phan Quang Hieu hieuphq

  • Dwarves Foundation
  • Vietnam
View GitHub Profile
@hieuphq
hieuphq / universal-framework.sh
Created March 31, 2017 11:29 — forked from Tokuriku/universal-framework.sh
Script to put in an Aggregate Target of a Framework in Xcode 6 to create a Universal Framework
#!/bin/sh
UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/${CONFIGURATION}-universal
# make sure the output directory exists
mkdir -p "${UNIVERSAL_OUTPUTFOLDER}"
# Step 1. Build Device and Simulator versions
xcodebuild -target "${PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -sdk iphoneos BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build
xcodebuild -target "${PROJECT_NAME}" -configuration ${CONFIGURATION} -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build
openssl genrsa -out privkey.pem 768
openssl pkcs8 -topk8 -nocrypt -in privkey.pem -out privkey2.pem
#!/bin/sh
UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/${CONFIGURATION}-universal
# make sure the output directory exists
mkdir -p "${UNIVERSAL_OUTPUTFOLDER}"
# Step 1. Build Device and Simulator versions
xcodebuild -target "${PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -sdk iphoneos BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build
xcodebuild -target "${PROJECT_NAME}" -configuration ${CONFIGURATION} -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build
# Step 2. Copy the framework structure (from iphoneos build) to the universal folder
cp -R "${BUILD_DIR}/${CONFIGURATION}-iphoneos/${PROJECT_NAME}.framework" "${UNIVERSAL_OUTPUTFOLDER}/"
# Step 3. Copy Swift modules from iphonesimulator build (if it exists) to the copied framework directory
  1. What does well-connected mean?

  2. Construct a directed-acyclic-graph (DAG) with approximately 100,000 randomly generated vertices and 99,999 randomly generated edges.
    Which means:
    100k vertices and 99,999 edges are randomly generated beforehand.
    Then we will use these 100k vertices and 99,999 edges to construct a complete DAG.
    This can lead to a complete DAG which has <= 100k vertices and <= 99,999 edges.
    Because when we generate edges, there might be a couple of edges which cause a cycle.
    For example: Vertex (4) and Vertex (7). We random generated 2 edges (4)-->(7) and (7)-->(4). And if this happens, it will leave a vertex which has no edge to connect to another vertex because we only have N vertices and N-1 edges.

@hieuphq
hieuphq / SynchronizedValue.swift
Created May 4, 2019 13:44
This template class make a value can be safe thread
/**
* Copyright (c) 2017 Razeware LLC
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*

Keybase proof

I hereby claim:

  • I am hieuphq on github.
  • I am hieutieutu (https://keybase.io/hieutieutu) on keybase.
  • I have a public key ASC7GkLEFU73-M4MDi1zCTIAvHf7pIqEJO9VJ8_IZ5RxTgo

To claim this, I am signing this object:

{"lastUpload":"2020-01-08T03:49:39.595Z","extensionVersion":"v3.4.3"}
Name: Flash
Serial: eNrzzU/OLi0odswsqnHLSSzOqDGoca7JKCkpsNLXLy8v1ytJTczVLUotKNFLzs8FAJHYETc=
if anyone wants to thank ETH: 0x527c2aB55b744D6167dc981576318af96ed26676
Thank you!
@hieuphq
hieuphq / gist:e7dd1a8bc9a07bfd53257db3cb8a211a
Created December 6, 2019 03:05
Deploying a Static HTML Site with Docker and Nginx
#### Build a directory for the website
- For front-end dev who using static files to host your web.
As usually, when you work with react lib, you use bundler(webpack, parcel, browser) to compile your project, you'll get a folder with static file.
What next will we do with those thing? Is it run stand alone locally by open index.html?
Nope, some reason for that is reference files in html follow format '/xxx.js'.It's an absolute path point to:
- public folder for php server
- uri
It should be './xxx.js'
So, you can use dockerfile to build an image with static files. You make a container to run that image.
Finally, you map a machine port to port 80 and enjoy your product at locally
import Foundation
open class EventBus {
struct Static {
static let instance = EventBus()
static let queue = DispatchQueue(label: "EventBus", attributes: [])
}