This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Models; | |
use App\Traits\ModelTableNameTrait; | |
class SampleMigration | |
{ | |
use ModelTableNameTrait; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Traits; | |
trait ModelTableNameTrait | |
{ | |
public static function name() { | |
return with(new static)->getTable(); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Illuminate\Database\Migrations\Migration; | |
use Illuminate\Database\Schema\Blueprint; | |
use Illuminate\Support\Facades\Schema; | |
class SampleMigration extends Migration | |
{ | |
/** | |
* Run the migrations. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"name": "Abia", | |
"cities": [ | |
"Aba South", | |
"Arochukwu", | |
"Bende", | |
"Ikwuano", | |
"Isiala Ngwa North", | |
"Isiala Ngwa South", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const storage = {} | |
app.post('/', textBodyParser, (req, res) => { | |
storage[req.hash] = storage[req.hash] || req.body.split('\n').map((line) => line.split('').reverse().join('')).join('\n') | |
res.send(storage[req.hash]) | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express') | |
const crypto = require('crypto') | |
const isPrime = require('./is-prime') | |
const app = express() | |
const calculateHash = function (req, res, buf, encoding){ | |
const hash = crypto.createHash('sha1') | |
hash.setEncoding('hex') | |
hash.write(buf.toString(encoding || 'utf8')) | |
hash.end() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express') | |
const textBodyParser = require('body-parser').text() | |
const isPrime = require('./is-prime') | |
const app = express() | |
app.post('/', textBodyParser, (req, res) => { | |
res.send(req.body.split('\n').map((line) => line.split('').reverse().join('')).join('\n')) | |
}) | |
app.get('/', (req, res) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express') | |
const app = express() | |
const storage = [] | |
app.get('/factorial', (req, res) => { | |
const rootUrl = (url) => req.protocol + '://' + req.get('host') + url; | |
const id = storage.length + 1; | |
setTimeout(() => { | |
let sum = 1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express') | |
const os = require('os') | |
const app = express() | |
const workerFarm = require('worker-farm') | |
const worker = workerFarm(require.resolve('./worker.js')) | |
app.get('/', (req, res) => { | |
const max = Number(req.query.max) || 1000 | |
worker(max, (err, primes) => { | |
if (err) res.status(500).send(err) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(() => { | |
const { spawn } = require('child_process'); | |
const ls = spawn('ls', ['-lh', '/usr']); | |
ls.stdout.on('data', (data) => { | |
console.log(`stdout: ${data}`); | |
}); | |
ls.stderr.on('data', (data) => { | |
console.log(`stderr: ${data}`); |