Skip to content

Instantly share code, notes, and snippets.

@nhanco
nhanco / google-img-resize.mdown
Created August 21, 2019 05:19
Google’s authentication-less on-the-fly image resizing service

Google's authentication-less on-the-fly image resizing service

I found it while poking around the Google+ HTML. Jotting down some notes felt like a good idea, so here goes. If you know more about this API, let me know, please!

(Word of warning: I spent ~30 minutes on both my experimentation and this here write-up, so it might not be the most thought-provoking, brilliant thing you read today.)

@nhanco
nhanco / add-jquery-bookmarklet.js
Last active April 16, 2019 12:16 — forked from rotten77/add-jquery-bookmarklet.js
Add jQuery to site (bookmarklet)
javascript:(function(){var script = document.createElement('script');script.src = '//ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js';document.getElementsByTagName('head')[0].appendChild(script);})();
javascript:(function(){var script = document.createElement('script');script.src = '//cdnjs.cloudflare.com/ajax/libs/axios/0.18.0/axios.min.js';document.getElementsByTagName('head')[0].appendChild(script);})();
<?php
$url = "http://www.phimmoi.net/phim/huyen-thoai-cua-ngay-mai-phan-4-7585/xem-phim.html";
$ch = curl_init();
{
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
@nhanco
nhanco / navigate.js
Created January 17, 2019 04:00
navigate
this.props.navigation.navigate("Configs", {
dayInfo: { hour: 13, day: 16, month: 1, year: 2019 }
})
@nhanco
nhanco / tomorrow.js
Created January 15, 2019 08:16
wtf bug
function tomorrow(str) {
var r = []
var d = new Date(str)
d.setDate(d.getDate() + 1)
r["year"] = d.getFullYear()
r["month"] = d.getMonth() + 1
r["day"] = d.getDate()
return r
}
@nhanco
nhanco / childrenWithProps.js
Created January 7, 2019 06:42
Send props color = this.props.color to all children
const { children } = this.props
const childrenWithProps = React.Children.map(children, child =>
React.cloneElement(child,{color:this.props.color})
)
@nhanco
nhanco / perssit.js
Created December 27, 2018 07:05
perssit bug
export const toggleConfig = key => ({ type: "TOGGLECONFIG", key })
const initialState = {
darkMode: false,
element: true,
compare: true,
god: true,
immortal: true,
trieu: true,
yTuong: true,
tangBo: true,
@nhanco
nhanco / nginx-dev-ssl.sh
Created July 7, 2018 16:02 — forked from LeZuse/nginx-dev-ssl.sh
nginx development SSL setup on localhost
# copy default OpenSSL config
cp /usr/local/etc/openssl/openssl.cnf .
# make changes according to https://fbcs.co.uk/self-signed-multiple-domain-ssl-certificates/
vim openssl.cnf
# [alt_names]
# DNS.1 = localhost
# IP.1 = 0.0.0.0
# IP.2 = 127.0.0.1
@nhanco
nhanco / client.js
Created March 26, 2018 15:20
csurf
exports.post = (urlPath, postData, callback) => {
axios.post(urlPath, qs.stringify(postData),{
headers: {'X-Requested-With': 'XMLHttpRequest'},
xsrfCookieName:'csrftoken',
xsrfHeaderName:'csrf-token',
data:postData
})
.then(function (response) {
callback(response)
@nhanco
nhanco / Login.js
Created March 7, 2018 14:51
[DOM] Password field is not contained in a form: (More info: https://goo.gl/9p2vKq) <input type=​"password" placeholder=​"Password" class=​"form-control">​
import React, { Component, PropTypes } from "react"
import { Form, FormGroup, Label, Button, Input, InputGroup, InputGroupAddon, InputGroupText } from "reactstrap"
export default class Login extends React.Component {
render() {
return (
<Form className="was-validated">
<InputGroup className="mb-3">
<InputGroupAddon addonType="prepend">
<InputGroupText>