Skip to content

Instantly share code, notes, and snippets.

View Pirolf's full-sized avatar

Yucheng Tu Pirolf

  • Aperture Science
  • City 17
View GitHub Profile
@Pirolf
Pirolf / imbalanced_dataset_lr_comparison.py
Created March 26, 2018 01:19 — forked from rnowling/imbalanced_dataset_lr_comparison.py
Imbalanced Dataset Logistic Regression Model Comparison
"""
Script for comparing Logistic Regression and associated evaluation metrics on the imbalanced Media 6 Degrees dataset from the Doing Data Science book. You'll need to download a copy of the dataset from the GitHub repo: https://github.com/oreillymedia/doing_data_science .
Copyright 2016 Ronald J. Nowling
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
@Pirolf
Pirolf / xsession.sh
Created February 13, 2018 17:00
X Session over SSH
export $DISPLAY=:0.0
ssh -Y pi@raspberrypi.local
/etc/X11/Xsession
#! /bin/bash
# streaming on Ubuntu via ffmpeg.
# see http://ubuntuguide.org/wiki/Screencasts for full documentation
# see http://www.thegameengine.org/miscellaneous/streaming-twitch-tv-ubuntu/
# for instructions on how to use this gist
if [ ! -f ~/.twitch_key ]; then
echo "Error: Could not find file: ~/.twitch_key"
echo "Please create this file and copy past your stream key into it. Open this script for more details."
@Pirolf
Pirolf / 0.setup.sh
Created February 18, 2016 05:11 — forked from ceteri/0.setup.sh
Spark Streaming demo
# using four part files to construct "minitweet"
cat rawtweets/part-0000[1-3] > minitweets
# change log4j properties to WARN to reduce noise during demo
mv conf/log4j.properties.template conf/log4j.properties
vim conf/log4j.properties # Change to WARN
# launch Spark shell REPL
./bin/spark-shell
@Pirolf
Pirolf / bootstrap_glyphs_in_rails.md
Created November 9, 2015 22:46 — forked from iamatypeofwalrus/bootstrap_glyphs_in_rails.md
Get Glyphicons up and running in Rails 3.2 without using a gem

Getting Glyphicons from Bootstrap 3.0 in Rails: the easy way

What

Bootstrap 3.0 gives you access to the awesome icon set icon set by these dudes but it's not obvious for a Rails newbie like myself to get it all working together nicely

How

  1. Download the bootstrap-glyphicons.css from here. Save that file to RAILS_ROOT/vendor/assets/stylesheet/bootstrap-glyphicons.css
  2. Save all the font files in /dist/fonts from the Bootstrap 3.0 download to a new folder in your Rails app RAILS_ROOT/vendor/assets/fonts
  3. Add this folder to the asset pipeline by appending config.assets.paths << Rails.root.join("vendor","assets", "fonts") to application.rb after the line that has class Application < Rails::Application.
  4. In bootstrap-glyphicons.css modify the the `url
@Pirolf
Pirolf / eyebeam.rb
Last active October 1, 2015 05:57
biu biu
=begin
#in main
# call:
firstObstacle = get_firs_obstacle(start_position, start_direction)
solve (firstObstacle, 0)
=end
# returns -1 if unsolvable (loop)
# otherwise distance traveled
mirrorHits = []
mirrorPositions = []
@Pirolf
Pirolf / secret_key_base
Created September 24, 2015 14:29 — forked from pablosalgadom/secret_key_base
app error: Missing `secret_key_base` for 'production' environment, set this value in `config/secrets.yml` (RuntimeError)
So i was using Rails 4.1 with Unicorn v4.8.2 and when i tried to deploy my app it doesn't start properly and into the unicorn.log file i found this error message:
"app error: Missing `secret_key_base` for 'production' environment, set this value in `config/secrets.yml` (RuntimeError)"
After a little research i found that Rails 4.1 change the way to manage the secret_key, so if we read the secrets.yml file located at exampleRailsProject/config/secrets.yml (you need to replace "exampleRailsProject" for your project name) you will find something like this:
# Do not keep production secrets in the repository,
# instead read values from the environment.
production:
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
Difficulty level: 1(easy) - 3(hard)
----Arrays-------
1. http://www.careercup.com/question?id=5133958972964864 3
2. http://www.careercup.com/question?id=5630275595796480 3
2. http://www.geeksforgeeks.org/kth-smallestlargest-element-unsorted-array/ 1
know how to find it when k is small (2,3). Write. Know that for larger k's, use a heap. Explain heap sort.
3. http://www.geeksforgeeks.org/find-the-largest-subarray-with-0-sum/ 2
4. http://www.geeksforgeeks.org/find-maximum-average-subarray-of-k-length/ 3
5. http://www.geeksforgeeks.org/find-the-element-that-appears-once-in-a-sorted-array/ 2
6. http://www.careercup.com/question?id=5926214520799232 2
@Pirolf
Pirolf / yummy things
Last active September 14, 2015 03:05
1. Return all words in the list with the prefix that user searched for. And without traverse the list every time
2. You have an array with words. Print them by anagrams groups
3. Given an array of strings with commit ids, and a predicate
isBuggy that returns if a single commit is buggy, write a program that finds the first buggy commit.
- When a commit is buggy, we assume that all its children are buggy.
- When a commit is not buggy, we assume that all its ancestors are not buggy.
4. Print all the possible words combination from a long string with no space.