Skip to content

Instantly share code, notes, and snippets.

View aloncarmel's full-sized avatar
🤘
❤️ Having fun!

Alon Carmel aloncarmel

🤘
❤️ Having fun!
View GitHub Profile
@aloncarmel
aloncarmel / CreateAirTableSyncedToAffinityList.md
Last active June 6, 2021 06:38
Creating an externally synced airtable base from affinity list

This is a small gist that allows you to share an org list from affinity to an airtable

Keeping airtable synced automatically. Below is an airtable structure that pulls via airtable script automation an affinity list, populates all the data throughout the list, populates the org data, people data and interlinks all records together directly via Affinity API. This can be adapted easily to populate Opprotunity and other objects from the affinity API. Feel free to share and contribute back.

Create a base that has the following tables with fields:

Main

Fields:

  1. 'Name' type of Single line text (should be default left side)
  2. 'entity_id' type of #number
  3. 'person_ids_json' type of Single line text
@aloncarmel
aloncarmel / PBIgetEmbedToken.php
Last active July 23, 2020 17:02
Embed a PowerBi Report using PowerBi JS library with AccessToken and EmbedToken
<?php
function getAccessToken() {
$curl = curl_init();
$data = array(
'client_id' => 'XXXXX',
'client_secret' => 'XXXX',
'grant_type' => "password",
@aloncarmel
aloncarmel / package.json
Created April 20, 2016 13:11
An Amazon lambda nodejs code that runs and waits for API calls coming in from a segment webhook configured. This lets you sync segment identify calls to salesforce. Its ready for a call from salesforce to update segment.
{
"name": "segmenttosalesforce",
"private": true,
"version": "0.0.1",
"description": " sync data across services",
"keywords": [],
"dependencies": {
"aws-sdk": "^2.0.17",
"request": "^2.44.0",
"bcrypt": "^0.8.0",
AtomAdapter.prototype.setOtherCursor = function(cursor, color, clientId) {
var clazz, css, cursorRange, end, justCursor, start, _ref,
_this = this;
if (this.otherCursors == null) {
this.otherCursors = {};
}
cursorRange = this.otherCursors[clientId];
if (cursorRange) {
@aloncarmel
aloncarmel / inserthtmltonode.js
Created August 13, 2014 12:51
Insert html into textnode
var selection = document.getSelection();
var cursorPos = selection.anchorOffset;
var oldContent = selection.anchorNode.nodeValue;
var toInsert = '_BUTTON_';
var newContent = oldContent.substring(0, cursorPos) + toInsert + oldContent.substring(cursorPos);
@aloncarmel
aloncarmel / killsockets.js
Created July 21, 2014 08:28
Fight renegade socket.io connections that try to kill your server
/*
Very simple solution for fighting renegade connections that try to overflood your socket.io server and kill your nodejs.
This limits number of connections and sends disconnect to the rest.
You can expend it by saving IP list in memory and handle uniqueness per IP also if you wish.
*/
//Start count
var connections = 0;
var maxconnections = 1000;
@aloncarmel
aloncarmel / socketconnect.js
Created July 13, 2014 11:30
Implement socket.io inside chrome extension or other internal JS files using jquery.
//Socket server connect to listen to data.
$.getScript('http://yoursocketioserver/socket.io/socket.io.js',function() {
socket = io.connect('http://lyoursocketioserver');
socket.on('connect', function(){
socket.on('message', function (data) {
@aloncarmel
aloncarmel / capture
Created January 23, 2014 15:20
A try to capture chrome pages using the pagecapture and create an image of them. NOT working.
chrome.pageCapture.saveAsMHTML({'tabId':1654}, function(mhtmlData){
var reader = new FileReader();
reader.readAsText(mhtmlData);
reader.onloadend = function() {
var html = reader.result;
d = document.createElement('div');
function setWeatherIcon(condid) {
switch(condid) {
case '0': var icon = '<i class="wi-tornado"></i>';
break;
case '1': var icon = '<i class="wi-storm-showers"></i>';
break;
case '2': var icon = '<i class="wi-tornado"></i>';
break;
case '3': var icon = '<i class="wi-thunderstorm"></i>';
@aloncarmel
aloncarmel / encryptor.js
Last active January 1, 2016 07:29
Encrypt and Decrypt text on nodejs with callbacks.
//Encrypt data, call callback when done for make sure everything is done.
function EncryptText(text,key,callback) {
console.log('Encrypting text');
var cipher = crypto.createCipher('aes-256-cbc',key)
var crypted = cipher.update(text,'utf8','hex')
crypted += cipher.final('hex');