Skip to content

Instantly share code, notes, and snippets.

Noitidart Noitidart

Block or report user

Report or block Noitidart

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Noitidart
Noitidart / e.js
Last active Jun 16, 2019 — forked from 1yzo/e.js
View e.js
if (typeof unreg !== 'undefined') unreg();
function logOnline() {
console.log('ONLINE', new Date().toLocaleTimeString())
}
function logOffline() {
console.log('offline', new Date().toLocaleTimeString())
}
function reg() {
window.addEventListener('online', logOnline);
View i++_vs_++i.js
pre(3); // log "hit" 3 times
post(3); // log "hit" 4 times
function pre(depth) {
let i=0;
while (true) {
console.log('hit');
if (++i === depth) return;
}
}
View swift-path-notes.md

with string of "file:///var/mobile/Containers/Data/Application/4CA477FA-1C4C-41C0-AF8D-094F364DE3BA/Documents/com.zillow.zo.rpm.dev/7C3DBCAA-0DC9-4224-A4D2-26803F032644.jpg"

doing:

  let urlString = path as String
  let url = NSURL(string: urlString)! as URL

url.path gives "/var/mobile/Containers/Data/Application/50235058-BF69-4311-A668-67D13F1566CA/Documents/com.zillow.zo.rpm.dev/7C3DBCAA-0DC9-4224-A4D2-26803F032644.jpg"

View node-request-errors.md
// server down
{ Error: connect ECONNREFUSED 127.0.0.1:1337
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1061:14)
  errno: 'ECONNREFUSED',
  code: 'ECONNREFUSED',
  syscall: 'connect',
  address: '127.0.0.1',
  port: 1337 }
View node-request-status-codes.txt
STATUS_CODES:
{ '100': 'Continue',
'101': 'Switching Protocols',
'102': 'Processing',
'103': 'Early Hints',
'200': 'OK',
'201': 'Created',
'202': 'Accepted',
'203': 'Non-Authoritative Information',
'204': 'No Content',
View _sails-socket-observer.js
/**
* A caveat is that an observer, referentially, can ONLY subscribe to one type.
* I can fix this in the future, but for now, I don't have a need.
*
* @param {"connect" | "reconnect" | "disconnect"} type
* @param {Function} observer
* @param {Object<string, any>} options
* @param {boolean} [options.shouldMulti] - Set to true if you want the observer to stay subscribed after first trigger. By default, it will be removed after first trigger.
*
View formatBytes.js
/**
* Convert a file size given in bytes to human readable sizes.
* Source: https://stackoverflow.com/a/18650828/1828637
*
* @param {number} bytes
* @param {number} decimals - Should be >= 0, if less than 0 it is adjusted to 0.
*/
function formatBytes(bytes, decimals = 2) {
if (bytes === 0) return '0 Bytes';
View exponential-retries.js
import * as _ from 'lodash';
_.times(18, i => 2 ** Math.floor(i / 2) * 1000),
_.times(28, i => Math.floor(i / 2) ** 2 * 1000)
View sails-cookie-in-react-native-fetch.txt
@Noitidart
Noitidart / stackoverflow-query-search-comments.txt
Last active May 6, 2019
Search for comments by tag of post
View stackoverflow-query-search-comments.txt
// https://data.stackexchange.com/stackoverflow/query/1027054/search-posts-by-userid-comment-text?CommentText=ios&TagName=react-native
SELECT Posts.Id AS [Post Link], Comments.Text, Comments.CreationDate
FROM Comments
LEFT JOIN Posts ON Posts.Id = Comments.PostId
WHERE UPPER(Comments.Text) LIKE UPPER('%##CommentText##%')
AND Comments.UserId = '1828637'
AND Posts.Tags LIKE '%<##TagName##>%'
ORDER BY Comments.CreationDate DESC
You can’t perform that action at this time.