Skip to content

Instantly share code, notes, and snippets.

@dchymko
dchymko / embed.js
Created April 23, 2020 22:10
CrowdSIgnal JS embed
<div class="pd-embed" id="pd_1587679595"></div>
<script type="text/javascript">
var _polldaddy = [] || _polldaddy;
_polldaddy.push( {
type: "iframe",
auto: "1",
domain: "automattic.survey.fm",
id: "bigwp2020",
placeholder: "pd_1587679595"
@dchymko
dchymko / gist:e448519433b70dcc9be02ea7a9c71fa7
Created April 23, 2020 22:08
CrowdSIgnal iFrame embed
<iframe frameborder="0" width="100%" height="600" scrolling="auto" allowtransparency="true" src="https://automattic.survey.fm/bigwp2020?iframe=1"><a href="https://automattic.survey.fm/bigwp2020">View Survey</a></iframe>
// Server
var socketio = require('socket.io');
var SocketIORedis = require('socket.io-redis');
const redis = require('redis');
var io1 = socketio.listen(8321);
//io1.adapter( SocketIORedis( { host: 'localhost', port: 6379 } ) );
const pub = redis.createClient(6379, 'localhost', { auth_pass: "" });
const sub = redis.createClient(6379, 'localhost', { auth_pass: "" });
io1.adapter(SocketIORedis({ pubClient: pub, subClient: sub }));
@dchymko
dchymko / FinstagramRemote.md
Last active April 5, 2017 00:28
Coding Fundamentals W05D01 connecting 2 Finstagram apps together

Linking two Finstagram apps

First thing you will need to decide is who will be the api and who will be the consumer.

Changes the api person needs to make

Change their project to be public instead of private (In the Cloud 9 Project settings)

Add a new route to provide the data in json format:

get '/api/posts/json' do
@dchymko
dchymko / StretchGoals.md
Last active April 6, 2017 02:23
Stetch Goals Lighthouse Labs W05D01

Stretch Goals

1) Create a Delete Post button

  • Create a form in the post view. Rememebr you have to use the action post and add a hiden input field called _method with the value of delete
  • Add a delete route in your actions RUb and find and delete (destroy) the post

2) Create an "Update Post" button

  • Reuse your post form partial
  • make the form PUT to a new endpoint (actions.rb)
  • add a new PUT rout to update the pist similar to how you created a new one? Remember how to make changes to an Active Record model instead of creating a new one?
@dchymko
dchymko / actions.rb
Created March 28, 2017 04:58
File upload in Sinatra for Lighthouse
get '/upload' do
erb (:upload)
end
post '/upload' do
if params[:file]
filename = params[:file][:filename]
file = params[:file][:tempfile]
file_dir = File.join(settings.public_folder, 'files')
File.open(File.join(file_dir, filename), 'wb') do |f|
@dchymko
dchymko / yellowpager.rb
Created March 20, 2017 04:28
Lighthouse Labs Yellow Pager example
def to_numbers(word)
if(word.size != 10)
return "not valid"
end
output = ""
word.chars.each do |letter|
output += to_number(letter.downcase).to_s
end
return output
end
@dchymko
dchymko / couchdb-ec2-install.sh
Created July 28, 2016 16:52 — forked from msmith/couchdb-ec2-install.sh
Set up CouchDB on EC2
#!/bin/bash
#
# This script installs and configures couchdb on a fresh Amazon Linux AMI instance.
#
# Must be run with root privileges
# Tested with Amazon Linux AMI release 2011.02.1.1 (ami-8c1fece5)
#
export BUILD_DIR="$PWD"
@dchymko
dchymko / compare.cs
Created February 28, 2012 04:44
C# pseudo-code to determine if your device/car/band is better than someone else's
/**********************************************************
Class: myFavoriteDevice
Desc: C# pseudo-code to determine if your device/car/band is better than someone else's
disclaimer: coded by hand inside gitHub, may require tweaking to compile.
***********************************************************/
Class myFavoriteDevice() Implements FavoriteThing {
string[] similarWords = new string[3] {"Ripoff", "Blatent Copy", "Patent Infringment"};
string[] differentWords1 = new String[4] {"failure", "abomination", "stupid name", "bad idea"};
string[] differentWords2 = new String[3] {"too many buttons", "not enough buttons", "sharp edges"};