Skip to content

Instantly share code, notes, and snippets.

View almazk's full-sized avatar

Almaz Kazakov almazk

  • Kazan, Tatarstan, Russia
  • 20:58 (UTC +03:00)
View GitHub Profile
$this->instance->request_body = [
'to' => $this->token->token,
'collapseKey' => $this->instance->topic,
'apns-collapse-id' => $this->instance->topic,
'Topic' => $this->instance->topic,
'collapse_key' => $this->instance->topic,
'time_to_live' => $this->instance->ttl ?: 3600,
'data' => [
'title' => $this->instance->notification['title'] ?? env('APP_NAME'),
'body' => $this->instance->notification['body'],
@rvanzon
rvanzon / readme.md
Last active November 8, 2017 21:08
Using Framework7-Vue from GitHub (instead of NPM)
  1. create a directory to place the framework.
  2. clone the repository git clone https://github.com/nolimits4web/Framework7-Vue
  3. cd Framework7-Vue
  4. npm install
  5. npm run dist
  6. go to your project and remove the Framework7-Vue: npm remove Framework7-Vue
  7. link the new package you just build: npm link <path to Framework7-Vue>

That's it!

@zcaceres
zcaceres / Error-Handling-Patterns-Express.md
Last active August 3, 2023 13:40
error handling patterns in Express

Handling Errors

Express.js makes it a breeze to handle errors in your routes.

Express lets you centralizes your error-handling through middleware.

Let's look at patterns for how to get the most out of your error-handling.

First, our error-handling middleware looks like this:

@guycalledseven
guycalledseven / manual-uninstall-paragon-ntfs.sh
Last active December 28, 2025 02:27
Manually remove Paragon NTFS v15 leftovers MacOS
# after appcleaner does his magic, do this
sudo rm -rf "/Library/Application Support/Paragon Software/"
sudo rm /Library/LaunchDaemons/com.paragon-software.installer.plist
sudo rm /Library/LaunchDaemons/com.paragon-software.ntfs.loader.plist
sudo rm /Library/LaunchDaemons/com.paragon-software.ntfsd.plist
sudo rm /Library/LaunchAgents/com.paragon-software.ntfs.notification-agent.plist
sudo rm -rf /Library/Filesystems/ufsd_NTFS.fs/
sudo rm -rf /Library/PrivilegedHelperTools/com.paragon-software.installer
sudo rm -rf /Library/Extensions/ufsd_NTFS.kext/
@jdx
jdx / boot.js
Last active October 1, 2025 10:57
zero-downtime node.js app runner
// This script will boot app.js with the number of workers
// specified in WORKER_COUNT.
//
// The master will respond to SIGHUP, which will trigger
// restarting all the workers and reloading the app.
var cluster = require('cluster');
var workerCount = process.env.WORKER_COUNT || 2;
// Defines what each worker needs to run
@bag-man
bag-man / cpu.js
Last active October 28, 2024 22:02
How to calculate the current CPU load with Node.js; without using any external modules or OS specific calls.
var os = require("os");
//Create function to get CPU information
function cpuAverage() {
//Initialise sum of idle and time of cores and fetch CPU info
var totalIdle = 0, totalTick = 0;
var cpus = os.cpus();
//Loop through CPU cores
@jpoehls
jpoehls / node-cluster-messaging.js
Created March 29, 2012 01:48
Simple message passing between cluster master and workers in Node.js
var cluster = require('cluster');
if (cluster.isWorker) {
console.log('Worker ' + process.pid + ' has started.');
// Send message to master process.
process.send({msgFromWorker: 'This is from worker ' + process.pid + '.'})
// Receive messages from the master process.
@lancejpollard
lancejpollard / node-folder-structure-options.md
Created November 28, 2011 01:50
What is your folder-structure preference for a large-scale Node.js project?

What is your folder-structure preference for a large-scale Node.js project?

0: Starting from Rails

This is the reference point. All the other options are based off this.

|-- app
|   |-- controllers
|   |   |-- admin