Skip to content

Instantly share code, notes, and snippets.

View glocore's full-sized avatar
🚀
Busy delivering packages!

Ashwin M glocore

🚀
Busy delivering packages!
View GitHub Profile
@getify
getify / 1.html
Last active May 10, 2023 03:25
Ever noticed how vw/vh units in CSS seem to be a bit unreliable on various devices (especially mobile)? Here's my solution.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0">
<title>Test Page</title>
<script>
// early compute the vw/vh units more reliably than CSS does itself
computeViewportDimensions();
@dagronf
dagronf / QueryExample.swift
Created February 10, 2019 00:53
How to use Spotlight searches in Swift (basic example)
let query = MDQueryCreate(kCFAllocatorDefault, "kMDItemContentType = com.apple.application-bundle" as CFString, nil, nil)
MDQueryExecute(query, CFOptionFlags(kMDQuerySynchronous.rawValue))
let count = MDQueryGetResultCount(query);
for i in 0 ..< count {
let rawPtr = MDQueryGetResultAtIndex(query, i)
let item = Unmanaged<MDItem>.fromOpaque(rawPtr!).takeUnretainedValue()
if let path = MDItemCopyAttribute(item, kMDItemPath) as? String {
print(path)
}
@kentbrew
kentbrew / pinmarklet.md
Last active April 9, 2024 18:34
How to recreate your long-lost Pinterest bookmarklet.

How to recreate your long-lost Pinterest bookmarklet.

Right-click your bookmarks bar and choose Add Page (Chrome) or New Bookmarklet (Firefox).

In Name, put this:

Pin It

In URL, put this:

@jarretmoses
jarretmoses / React Native Clear Cache
Last active March 11, 2024 10:20
Clearing the Cache of your React Native Project
RN < 0.50 - watchman watch-del-all && rm -rf $TMPDIR/react-* && rm -rf node_modules/ && npm cache clean && npm install && npm start -- --reset-cache
RN >= 0.50 - watchman watch-del-all && rm -rf $TMPDIR/react-native-packager-cache-* && rm -rf $TMPDIR/metro-bundler-cache-* && rm -rf node_modules/ && npm cache clean && npm install && npm start -- --reset-cache
RN >= 0.63 - watchman watch-del-all && rm -rf node_modules && npm install && rm -rf /tmp/metro-* && npm run start --reset-cache
npm >= 5 - watchman watch-del-all && rm -rf $TMPDIR/react-* && rm -rf node_modules/ && npm cache verify && npm install && npm start -- --reset-cache
Windows - del %appdata%\Temp\react-native-* & cd android & gradlew clean & cd .. & del node_modules/ & npm cache clean --force & npm install & npm start -- --reset-cache
@staltz
staltz / introrx.md
Last active May 2, 2024 12:31
The introduction to Reactive Programming you've been missing
@cemerson
cemerson / st3-snippet-editing.txt
Created March 24, 2014 09:50
Sublime Text: Editing Snippets
Sublime Text 3 stores its packages in .sublime-package zip files, so unlike ST2 you can't just go to the Packages folder and see everything. However, there is an excellent plugin called PackageResourceViewer (available via Package Control) that can, among other things, extract files or whole packages to the Packages directory.
Once you've installed the plugin, hit CtrlShiftP to open the command palette, and type prv to get the Package Resource Viewer: options. Select Package Resource Viewer: Open Resource, navigate down the list to LaTeX, then open the section-..-(section).sublime-snippet file. You should now be able to edit this file and save it, which will create a new file Packages/LaTeX/section-..-(section).sublime-snippet that you can open directly via the file menu if you need to alter it again.
@tomquas
tomquas / xmpp server comparison
Last active September 10, 2020 16:41
performance testing prosody, tigase, ejabberd
motivation
* test xmpp bot behavior with different servers, measure throughput and reliability.
* figure out numbers for prosody, nothing seems to be published at the time of writing
* the goal was _not_ to push the servers to their limits, so the test environment was not highly optimized.
test setup
* macbook pro hosting ubuntu raring on vmware fusion.
* communication flow: xmpp client (osx) > xmpp server (ubuntu) > xmpp bot (osx).
* client opens 20 connections to server and pumps 150 iq stanzas (similar disco#items) to bot. this is being repeated 40x.
* servers:
@sevastos
sevastos / aws-multipartUpload.js
Last active October 8, 2023 10:43
Example AWS S3 Multipart Upload with aws-sdk for Node.js - Retries to upload failing parts
// Based on Glacier's example: http://docs.aws.amazon.com/AWSJavaScriptSDK/guide/examples.html#Amazon_Glacier__Multi-part_Upload
var fs = require('fs');
var AWS = require('aws-sdk');
AWS.config.loadFromPath('./aws-config.json');
var s3 = new AWS.S3();
// File
var fileName = '5.pdf';
var filePath = './' + fileName;
var fileKey = fileName;
@tsabat
tsabat / zsh.md
Last active December 25, 2023 19:16
Getting oh-my-zsh to work in Ubuntu