Skip to content

Instantly share code, notes, and snippets.

View ldco2016's full-sized avatar
🏠
Working from home

Daniel Cortes ldco2016

🏠
Working from home
  • Jacksonville, TX
View GitHub Profile
@ldco2016
ldco2016 / Ruby.txt
Created July 26, 2016 03:01
Ruby code that flattens an array of arbitrarily nested arrays of integers into a flat array of integers.
DCortes-MBP-3:~ ldco2016$ irb
2.3.0 :001 > def flattify(array)
2.3.0 :002?> array.each_with_object([]) do |element, flattened|
2.3.0 :003 > flattened.push *(element.is_a?(Array) ? flattify(element) : element)
2.3.0 :004?> end
2.3.0 :005?> end
=> :flattify
2.3.0 :006 > flattify([1,2,3,4,[1,2,3,4],5])
=> [1, 2, 3, 4, 1, 2, 3, 4, 5]
2.3.0 :007 >
@ldco2016
ldco2016 / gist:99f9a366b0e2573cf3d494c894111d1b
Created September 1, 2016 19:21
WordPress Image Upload Errors
37840.png
The uploaded file could not be moved to wp-content/uploads/2016/09.
37840.png
Unable to create directory wp-content/uploads/2016/09. Is its parent directory writable by the server?
@ldco2016
ldco2016 / gist:f306fa205e263f99b4fe961570f9f9df
Created September 15, 2016 03:13
Full Stack Mentor - Assessment
JavaScript
Hey mentor,
I was working through an assignment last night and came across a bug. I'm so confused!
The text in the alert is showing up as "undefined" instead of either "A Unicorn", "A hug", or "Fresh Laundry" and I'm not quite sure what's going on. Can you point me in the right direction?
-Student
@ldco2016
ldco2016 / chaser.html
Created October 24, 2016 02:57
Code Test
<!DOCTYPE html>
<html>
<body>
<script>
// person constructor
function Person(name, rank) {
this.name = name;
this.rank = rank;
@ldco2016
ldco2016 / gist:117b8a16a3644226b6132da90ccf41f0
Created November 9, 2016 02:36
evolution of sign up form
<h2 class='text-center'>Sign up</h2>
<div class="row">
<div class="col-md-12">
<%= form_for(resource, as: resource_name, :html => {class: "form-horizonal", role: "form"}, url: registration_path(resource_name)) do |f| %>
<%= devise_error_messages! %>
</div>
</div>
<div class="form-group">
danales-MacBook-Pro:iris danale$ node bin/run.js
Logged in as microurb of team urban-farming, but not yet connected to a channel
iris is listening on 3000 in development mode.
{ Error: Internal Server Error
at Request.callback (/Users/danale/Projects/iris/node_modules/superagent/lib/node/index.js:675:11)
at /Users/danale/Projects/iris/node_modules/superagent/lib/node/index.js:883:18
at IncomingMessage.<anonymous> (/Users/danale/Projects/iris/node_modules/superagent/lib/node/parsers/json.js:16:7)
at emitNone (events.js:91:20)
at IncomingMessage.emit (events.js:185:7)
at endReadableNT (_stream_readable.js:974:12)
@ldco2016
ldco2016 / caesar-cipher.js
Created November 12, 2017 18:26 — forked from primaryobjects/caesar-cipher.js
Caesar Cipher algorithm, encrypt string wrap back around to letters
process.stdin.resume();
process.stdin.setEncoding('ascii');
var input_stdin = "";
var input_stdin_array = "";
var input_currentline = 0;
process.stdin.on('data', function (data) {
input_stdin += data;
});
function main() {
var S = readLine();
const expectedSignal = 'SOS';
let errorCount = 0;
for (i = 0, len = S.length; i <len; i += 3) {
const currentSignal = S.slice(i, i + 3);
if (currentSignal === expectedSignal) continue;
if (currentSignal[0] !== expectedSignal[0]) errorCount += 1;
if (currentSignal[1] !== expectedSignal[1]) errorCount += 1;
function main() {
var n = parseInt(readLine());
var a = [];
for(a_i = 0; a_i < n; a_i++){
a[a_i] = readLine().split(' ');
a[a_i] = a[a_i].map(Number);
}
let sumPrimaryDiagonal = sumSecondaryDiagonal = 0;
function main() {
var n = parseInt(readLine());
arr = readLine().split(' ');
arr = arr.map(Number);
let positive = negative = zero = 0;
for (i =0; i < n; i++){
let current = arr[i];
if (current > 0) {
positive += 1;