Mysql collate, searching case sensitive
Usually our mysql queries are not case sensitive. In order to query case sensitive, you can use the mysql COLLATE clause.
The collate clause lets you specify a collation, which basically is a set of rules for comparing characters in a given character set.
The suffixes ci, cs, bin of a collation stand for case insensitive, case sensitive and binary, respectively. A binary collation such as utf8_bin is case sensitive as well since it compares the characters based on their numeric values.
SELECT * FROM use...
Ruby: The & operator
After reading, you will know why and how runners.each(&:run)
works. Here some tidbits:
& can be quite confusing because it has a different meaning depending on the context in which it's used.
&object is evaluated in the following way:
- if object is a block, it converts the block into a simple proc.
- if object is a Proc, it converts the object into a block while preserving the lambda? status of the object.
- if object is not a Proc, it first calls #to_proc on the object and then converts it into a block.
Legacy docs for Font Awesome 3.2.1
Font Awesome 4 has renamed all icons. What the fuck.
Check the attached link for an icon list for the old Font Awesome 3.2.1.
Note
The following icons are listed on the linked page but may not exist in your vendored font:
icon-adn
icon-align
icon-ambulance
icon-anchor
icon-android
icon-angle
icon-apple
icon-archive
icon-arrow
icon-ban
icon-bar
icon-beer
icon-bitbucket
icon-btc
icon-bug
icon-building
icon-bullseye
icon-caret
icon-chevron
icon-circle
icon-cny
icon-code
icon-coffee
icon-col...
Texture Mixin for Sass
Awesome Sass plugin to experiment with Subtle Patterns based textures. It automatically removes the base color from the pattern, leaving a semi-transparent texture that you can tint in any color you want. It also has switches to invert the pattern.
@include texture(green, 34, 0); // color, texture-number, 0=inverted or 1=normal
If you have ever done this manually you know how much pain this can safe you. Check it out!
weighttp - a lightweight and simple webserver benchmarking tool
Weighttp is threaded and might exhaust resources of an application better than ApacheBench or httperf.
You need libev installed.
sudo apt-get install libev-dev
./waf configure
sudo ./waf install
The top responsive web design problems ... and how to avoid them
I recently created a survey asking fellow designers about the problems they faced when creating fully responsive sites. This article will list the most common problems they reported and offer possible solutions, along with suggestions to consider on your next projects.
HubSpot/mixen · GitHub
It's mixins (modules) for Coffeescript classes. Other than most homegrown approaches, this one allows you to keep using super
.
Carrierwave – Recreate versions
A snippet of the carrierwave documentation
You might come to a situation where you want to retroactively change a version or add a new one. You can use the recreate_versions! method to recreate the versions from the base file. This uses a naive approach which will re-upload and process the specified version or all versions, if none is passed as an argument.
Call recreate_versions!
on a mounted uploader.
A common usecase
User.all.each { |user| user.avatar.r...
Allow setting the #id attribute when creating an ActiveRecord
When creating an ActiveRecord with .new
, .create
or create!
, you cannot set the ID attribute (note: When using Machinist's .make
you can).
This is because even when you are not using attr_protected
or attr_accessible
, some attributes are always protected. These attributes are #id
and #type
.
If you want to allow setting #id
on .new
, .create
or create!
you can include the attached module in order to whitelist #id
on a model of your choice like this:
class MyModel <...
Installation of therubyracer fails with "undefined method `include_path'"
Today I ran into trouble installing therubyracer on Ruby 1.8. The installation failed with
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
...
What you need to know about Angular SEO
Search engines, such as Google and Bing are engineered to crawl static web pages, not javascript-heavy, client-side apps. This is typical of a search engine which does not render javascript when the search bot is crawling over web pages.
This is because our javascript-heavy apps need a javascript engine to run, like PhantomJS or v8, for instance. Web crawlers typically load a web page without using a javascript interpreter.
Are we out of luck for providing good SEO for our Angular apps? This article will show you exactly what you nee...
safe_cookies is now in public beta
We proudly release our safe_cookies middleware into public beta and just published it on Github.
Features are:
- make all application cookies
secure
andHttpOnly
(keeping them from being sent over HTTP and protecting them from Javascript) - rewrite all client cookies once, making them
secure
andHttpOnly
- notification if a request has unregistered cookies (no unsecure cookie will slip by)
- ability to ignore external cookies, like
__utma
and other tracking cookies - easy configurat...
Get Moving With Angular 1.2 Animation and Animate.css
Motion is quickly becoming one of the most important emerging techniques in building a quality user experience on the web. Angular 1.2, currently in release candidate form, provides an overhaul of Angular's animation system and makes it spectacularly easy to bring your interface to life.
International Address Fields in Web Forms :: UXmatters
Advice for address forms that work with address structures from multiple countries.
Stubbing out external services with an embedded Sinatra application
One of many useful techniques when your test suite needs to talk to a remote API.
Enable NewRelic monitoring [for Rails] on specific hosts only
If you need to enable NewRelic monitoring on certain machines within the same Rails environment, a simple solution is to utilize the respective hostnames of you machines.
For example, if you have 8 application servers (e.g. app1.example.com
, app2.example.com
, ...) and want to enable NewRelic on app1
and app2
only, utilize those steps to do so:
- Put the attached file into your config directory (
config/custom_new_relic_configuration.rb
). - Specify on which hosts NewRelic should be enabled (see
NEWRELIC_HOSTS
constant and list ...
Spreewald 0.6.7 "follow link in email"-step won't match backslashes any longer
When you build a link for an email body like this
body = "Please click the following link"
body << "http://posts/130\n\n"
body << "Members:"
...
then updating Spreewald to >=0.6.7 will be able to parse it correctly.
Spreewald 0.6.6 improves the Timezone switch
When you run into time zone issues e.g.
Given the time is "2011-11-11 11:11"
but
Time.now => ... 13:11
then updating Spreewald to >=0.6.6 might fix it.
Fix "An error occurred while installing debugger-linecache" with Ruby 1.9.3
You're better off using debugger-ruby_core_source
:
gem install debugger-ruby_core_source
If you can't do this, try the following.
Here is how to fix the following error when installing the debugger
gem fails:
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension
Note: The following example is for a project using Ruby 1.9.3-p448 -- adjust accordingly for your project.
-
Fetch the source for your Ruby version, if you do not yet have it:
rvm fetch ruby-1.9.3-p448
-
Install t...
Geordi: Choose your firefox version for cuc
Geordi 0.16+ supports running selenium tests with project-specific firefox versions.
Just update the gem. It will still default to using the old 5.0.1 firefox. If you want another one, add a file .firefox-version
to your project, containing your preferred version.
geordi cucumber
will prompt (and guide) you to install the given version. You can delete any old installation sitting in /opt/firefox-for-selenium
if you have one.
Speeding up ssh session creation
Establishing a new SSH connection usually takes only a few seconds, but if you’re connecting to a server multiple times in succession the overhead starts to add up. If you do a lot of Git pushing and pulling or frequently need to SSH to a dev server, you’ve probably felt the pain of waiting for SSH to connect so you can get back to doing work.
Implementing social media "like" buttons: Everything you never wanted to know
So you client has asked you to implement a row of buttons to like the URL on Facebook, Twitter and Google+. Here are some things you should know about this.
0. Security considerations
Each "like" button is implemented by including a Javascript on your site. This means you are running fucking remote code on your page. You are giving Facebook, Twitter and Google+ full permission to e. g. copy user cookies. Check with your client if she is cool with that. Also note that if you're site is suggesting security by operating under HTTPS ...
Enable CSRF protection in Javascript tests
You might not know that Rails disables CSRF protection in tests. This means that if you accidentally forget to send the CSRF token for non-GET requests, your tests will be green even though your application is completely broken (a failed CSRF check usually logs out the user). Rails probably does this because CSRF protection sort of requires Javascript.
You want to enable CSRF protection in Cucumber scenarios that can speak Javascript. To do so, copy the a...