Skip to content

Instantly share code, notes, and snippets.

View he-and-her's full-sized avatar
Value Loyalty. Above. All. Else.

olive he-and-her

Value Loyalty. Above. All. Else.
View GitHub Profile
@he-and-her
he-and-her / debuggingreact.js
Last active April 25, 2017 03:55
Weird errors in React/JS
// You have this
// file name: SomethingComponent.jsx
export default class SomethingContainer
extends React.Component {
render() {
...
}
}
@he-and-her
he-and-her / decode_session.rb
Last active April 25, 2017 03:57
decode session
key_generator = ActiveSupport::KeyGenerator.new(
Rails.application.config.secret_key_base,
iterations: 1000)
secret = key_generator.generate_key(
Rails.application.config
.action_dispatch
.encrypted_cookie_salt)
salt = key_generator.generate_key(
@he-and-her
he-and-her / handle_option.rb
Created April 16, 2017 03:33
handle_options method from action_dispatch
def handle_options(options) #:nodoc:
options[:path] ||= "/"
if options[:domain] == :all || options[:domain] == "all"
domain_regexp = options[:tld_length] ? /([^.]+\.?){#{options[:tld_length]}}$/ : DOMAIN_REGEXP
options[:domain] = if (request.host !~ /^[\d.]+$/) && (request.host =~ domain_regexp)
".#{$&}"
end
elsif options[:domain].is_a? Array
options[:domain] = options[:domain].find { |domain| request.host.include? domain.sub(/^\./, "") }
@he-and-her
he-and-her / nginx.conf
Last active April 25, 2017 03:59
Calling a shell with nginx et la.
location /deploy {
gzip off;
fastcgi_pass unix:/var/run/fcgiwrap.socket;
include /etc/nginx/fastcgi_params;
fastcgi_param DOCUMENT_ROOT /site;
fastcgi_param SCRIPT_FILENAME /site/update.sh;
fastcgi_param SCRIPT_NAME /site/update.sh;
return 204;
}
@he-and-her
he-and-her / filecontent.js
Last active April 25, 2017 04:00
Files content a là jQuery
$.get("url/" + file.name, function(data) {
console.log(data);
});
@he-and-her
he-and-her / filenames.js
Last active April 25, 2017 04:01
Filenames from listing nginx feature
$.ajax({
url: "url",
success: function(data) {
data.forEach(function(file) {
console.log(file.name)
})
},
error: function(error) {
alert("Mérdé.")
}
@he-and-her
he-and-her / cors.js
Last active April 15, 2017 20:20
CORS nginx.
location / {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range';
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain charset=UTF-8';
add_header 'Content-Length' 0;
return 204;
}
@he-and-her
he-and-her / nginx.conf
Last active April 25, 2017 04:01
Listing directory with Nginx
server {
# USUAL SHIT ...
location /some_directory {
autoindex on;
}
}
@font-face {
font-family: "Proxima Nova";
src: url(data:font/opentype;base64,d09GRgABAAAAAEywABIAAAAAg3QAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABEWU5BAAAGbAAAALgAAAGJNI0oHkZGVE0AAAGUAAAAHAAAABxdnq2WR0RFRgAAByQAAAA4AAAAQgSqBTxHUE9TAAAHXAAABCIAABH0zI0AF09TLzIAAAXUAAAAVwAAAGCAz3p9Y21hcAAASvgAAAG2AAAC5lCJVL9jdnQgAAABsAAAAB4AAAAeCkcLCmZwZ20AAAHQAAABsgAAAmUjtC+nZ2FzcAAAA4QAAAAIAAAACAAAABBnbHlmAAALgAAAO4sAAF8I3FzIU2hlYWQAAAOMAAAANQAAADb9TDtqaGhlYQAABiwAAAAgAAAAJA9PBsBobXR4AABHDAAAAh8AAANsqw8hfGxvY2EAAEksAAABuAAAAbhtqYQ8bWF4cAAABkwAAAAgAAAAIAIDAhpuYW1lAAADxAAAAawAAANRLIw+gnBvc3QAAErkAAAAEwAAACD/DQAocHJlcAAABXAAAABjAAAAdNUcAaMAAAABAAAAAMmJbzEAAAAAyRrF1wAAAADK+niN/pAAAAPGBTYBYADCANABNgE+AWgBmQDkAZIBkAFYAAB42l1Ru05bQRDdDQ+TBBJjg+RoU8xmQhrvhYYCJBBXF8XIdmM5QtqNXORiXMAHUCBRg/ZrBmgoKdKmQcgFUj6BT0BiZk2iKM3Ozuycc+bMknKk6l1a73nqnARSuNOg2abfDql2FuCedH21kZF28EDzzYxeuW7ff8VgM5pyRw2gvOct5SGjaSdQi/bU/za/guE+/2Qeg0FLM01PrZOQHkJgvhm3MPie0ay7/KQvWB0uBgNDimkq7vJzKuV/S3Outgibaxm9dnAmIj+ZBmhqpY1A0186pHo+jmIJctkw1gYTU9afZCL4ZjJd1VQtM751cJfszDt
@he-and-her
he-and-her / skwer_part_2.go
Created February 24, 2017 05:56
for blog
anAtom := NewAtom(1, 1, 255)
// We can only access the methods defined within the interface
anAtom.GetColor() // gut!
anAtom.GetPosition() // gut!
anAtom.GetSomething() // wrong! an error you will get when you try run it.