Skip to content

Instantly share code, notes, and snippets.

View foo4foo's full-sized avatar
🎯
Focusing

Stefan Kikanović foo4foo

🎯
Focusing
  • Novi Sad, Serbia
View GitHub Profile
@foo4foo
foo4foo / nodejs-tcp-example.js
Created July 12, 2017 11:58 — forked from tedmiston/nodejs-tcp-example.js
Node.js TCP client and server example
/*
In the node.js intro tutorial (http://nodejs.org/), they show a basic tcp
server, but for some reason omit a client connecting to it. I added an
example at the bottom.
Save the following server in example.js:
*/
var net = require('net');
@foo4foo
foo4foo / tutorial.md
Created November 10, 2018 16:26 — forked from Hinsei/tutorial.md
Using Cloudinary With CarrierWave Rails

Uploading Files To A Cloud Via Cloudinary and CarrierWave with Rails

This is a tutorial on how to use Cloudinary cloud services with carrierwave to upload files, in this case we would like to use it for image uploading for our users avatar

Sign Up For A Cloudinary Account

Cloudinary -> Sign up for an account here!

Take Note Of Details In Your Dashboard

After successfuly signing up, you will be redirected to your dashboard.

@foo4foo
foo4foo / client.js
Created November 17, 2018 22:15 — forked from crtr0/client.js
A simple example of setting-up dynamic "rooms" for socket.io clients to join
// set-up a connection between the client and the server
var socket = io.connect();
// let's assume that the client page, once rendered, knows what room it wants to join
var room = "abc123";
socket.on('connect', function() {
// Connected, let's sign-up for to receive messages for this room
socket.emit('room', room);
});
@foo4foo
foo4foo / upload.js
Created December 19, 2018 17:56 — forked from cmcewen/upload.js
Upload image from React Native to Cloudinary
var CryptoJS = require('crypto-js');
function uploadImage(uri) {
let timestamp = (Date.now() / 1000 | 0).toString();
let api_key = 'your api key'
let api_secret = 'your api secret'
let cloud = 'your cloud name'
let hash_string = 'timestamp=' + timestamp + api_secret
let signature = CryptoJS.SHA1(hash_string).toString();
let upload_url = 'https://api.cloudinary.com/v1_1/' + cloud + '/image/upload'
@foo4foo
foo4foo / cloudflareworker-verifyjwt.js
Created April 8, 2021 00:19 — forked from bcnzer/cloudflareworker-verifyjwt.js
Sample Cloudflare worker that gets the JWT, ensures it hasn't expired, decrypts it and returns a result
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request))
})
// Following code is a modified version of that found at https://blog.cloudflare.com/dronedeploy-and-cloudflare-workers/
/**
* Fetch and log a request
* @param {Request} request
*/
@foo4foo
foo4foo / base64.js
Created April 11, 2021 22:08 — forked from enepomnyaschih/base64.js
https://www.npmjs.com/package/byte-base64 - Encode JS Uint8Array, simple array of bytes or native JS string to base64 and back
/*
MIT License
Copyright (c) 2020 Egor Nepomnyaschih
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is