Skip to content

Instantly share code, notes, and snippets.

@JulienKode
JulienKode / circleci.js
Last active November 21, 2019 21:08
CircleCi example of setup for monorepo: https://tech.julienkarst.com/how-to-setup-circleci-inside-a-monorepo | We will see how to use the CircleCI API to trigger workflow
const fetch = require('node-fetch');
const { exec } = require('child_process');
const modules = ['core', 'components'];
exec('npx lerna changed --all', (error, stdout) => {
modules.forEach(name => {
if (!stdout.includes(name)) return;
const params = {
jobs:
trigger-workflows:
executor: node
steps:
- run:
name: Trigger workflows
command: node ./circleci.js
workflows:
version: 2
# The main workflow will trigger other workflow based on your changes
trigger:
when: << pipeline.parameters.trigger >>
jobs:
- trigger-workflows
- new_version:
requires:
version: 2.1
parameters:
# By default we enable the main workflow
trigger:
type: boolean
default: true
# Add a boolean parameter on each package.
core:
@JulienKode
JulienKode / dectectors.swift
Created April 14, 2019 08:41
Change detectors attributes based on DetectorType for MessageKit
extension MyAwesomeViewController: MessagesDisplayDelegate {
// ...
func detectorAttributes(for detector: DetectorType, and message: MessageType, at indexPath: IndexPath) -> [NSAttributedString.Key: Any] {
switch detector {
case .hashtag:
return [.foregroundColor: UIColor.white]
case .custom:
return [.foregroundColor: UIColor.black]
@JulienKode
JulienKode / detectors.swift
Created April 14, 2019 08:22
Enable custom detectors with MessageKit
extension MyAwesomeViewController: MessagesDisplayDelegate {
// ...
func enabledDetectors(for message: MessageType, at indexPath: IndexPath, in messagesCollectionView: MessagesCollectionView) -> [DetectorType] {
return [.hashtag, .custom(try! NSRegularExpression(pattern: "@[a-zA-Z0-9]{4,}", options: [])) ]
}
// ...
@JulienKode
JulienKode / example.swift
Created January 8, 2019 15:24
How to change the cancel button color of the search bar ?
let cancelButtonAttributes = [NSAttributedString.Key.foregroundColor: UIColor.white]
UIBarButtonItem.appearance(whenContainedInInstancesOf: [UISearchBar.self]).setTitleTextAttributes(cancelButtonAttributes, for: .normal)
@JulienKode
JulienKode / Date+TimeAgo.swift
Created December 2, 2018 07:42
Simple example to display Time ago from a Date in Swift
extension Date {
func timeAgoDisplay() -> String {
let calendar = Calendar.current
let minuteAgo = calendar.date(byAdding: .minute, value: -1, to: Date())!
let hourAgo = calendar.date(byAdding: .hour, value: -1, to: Date())!
let dayAgo = calendar.date(byAdding: .day, value: -1, to: Date())!
let weekAgo = calendar.date(byAdding: .day, value: -7, to: Date())!
if minuteAgo < self {
@JulienKode
JulienKode / xmrstack.service
Created September 7, 2018 21:25
xmr-stak service example
[Unit]
Description=XMR STAK Daemon
After=network.target
[Service]
Type=forking
GuessMainPID=no
ExecStart=/usr/local/bin/xmr-stak -c /home/miner/config/config.txt -C /home/miner/config/pools.txt --cpu /home/miner/config/cpu.txt
Restart=always
User=miner
@JulienKode
JulienKode / pools.txt
Created September 7, 2018 21:11
Pool config xmr-stak
/*
* pool_address - Pool address should be in the form "pool.supportxmr.com:3333". Only stratum pools are supported.
* wallet_address - Your wallet, or pool login.
* rig_id - Rig identifier for pool-side statistics (needs pool support).
* pool_password - Can be empty in most cases or "x".
* use_nicehash - Limit the nonce to 3 bytes as required by nicehash.
* use_tls - This option will make us connect using Transport Layer Security.
* tls_fingerprint - Server's SHA256 fingerprint. If this string is non-empty then we will check the server's cert against it.
* pool_weight - Pool weight is a number telling the miner how important the pool is. Miner will mine mostly at the pool