Skip to content

Instantly share code, notes, and snippets.

View chestozo's full-sized avatar

chestozo

  • Portugal
  • 11:32 (UTC +01:00)
View GitHub Profile
mysql -u root -D ‘yourdatabase’ -e “UPDATE wp_posts SET post_content=’`cat your-local-file.html | perl -i -pe “s/’/\\\\\\’/g”`’ WHERE ID=6826"
SELECT * FROM `yourdatabase`.wp_posts WHERE post_status=’publish’ order by post_date DESC
/*
* -----------------------------------------------------------------------------------------------------------------------
* Sirvoy Booking Widget, (c) Sirvoy Ltd 2014, All rights reserved.
* -----------------------------------------------------------------------------------------------------------------------
*
* Usage:
*
* To include the booking widget on your page, just add the following html to your page:
* <script async type="text/javascript" src="https://secured.sirvoy.com/widget/sirvoy.js" data-form-id="your-token-here"></script>
*
// Based on https://code.google.com/p/google-diff-match-patch/wiki/LineOrWordDiffs.
diff_match_patch.prototype.diff_linesToWords_ = function(text1, text2) {
var lineArray = [];
var lineHash = {};
lineArray[0] = '';
function diff_linesToCharsMunge_(text) {
var chars = '';
var lineStart = 0;
@chestozo
chestozo / touch-scroll-minix.jsx
Last active October 7, 2023 13:51
react.js mixin for inertial scroll (momentum scroll) on touch devices
/**
On touch devices we have an intertial scroll effect (also called momentum scroll)
that is hard to detect (with scrollTop property for example).
See this article for problem details http://andyshora.com/mobile-scroll-event-problems.html
Still it is possible to detect inertial scroll by calculating velocity
with which user is scrolling element.
In this gist we use velocity formula from this article:
http://ariya.ofilabs.com/2013/11/javascript-kinetic-scrolling-part-2.html
@chestozo
chestozo / sinon.fakeServer.autoRespondAfter.js
Created September 15, 2014 08:27
Dynamic value for sinon fakeServer autoRespondAfter property
var server = sinon.fakeServer.create();
server.autoRespond = true;
Object.defineProperty(server, 'autoRespondAfter', {
get: function() {
if (someSmartCondition) {
return 100;
}
return 10;
@chestozo
chestozo / al.txt
Created August 21, 2014 12:59
markdown-like on al
@main[] ^header[Создание плаката ко Дню независимости Украины (2014)] ^maindir[]
^include[../../holidays.p]
^tabs_poster_son[]
^include[../../ukraine-independence-day.p]
^tabs_son[]
Создание плаката ко Дню независимости Украины (2014)
^include[../auto.p]
describe('do not reset model status to ok if it was in error status', function() {
beforeEach(function() {
ns.Model.define('model1');
ns.Model.define('model2');
this.xhr = sinon.useFakeXMLHttpRequest();
this.xhr.onCreate = function(xhr) {
window.setTimeout(function() {
xhr.respond(
@chestozo
chestozo / view-bindModels.js
Created January 23, 2014 18:07
noscript bindModels test case
describe('redraw old view when model was invalidated', function() {
// https://github.com/yandex-ui/noscript/pull/192#issuecomment-33148362
// После починки _unbindModels перестало работать обновление view при изменении модели.
// Дело тут в том, что view подписана на своим модели. Модель поменялась - view перерисовалась (model ns-model-changed -> view invalidate).
// Когда мы починили отписку view от модели (во время _hide) изменения модели больше не будут услышаны view (что, как бы, хорошо и by design).
// Но тогда, во время update-а надо проверять, что все модели view валидны. И если нет - обновлять view.
// Итог: не отписываем view от моделей
var goToPage = function(app, params, callback) {
@chestozo
chestozo / logwrapper.js
Last active October 26, 2016 16:17
Log all calls to some object by wrapping all his methods
var lw = {
wrap: function(type, onlyOwnProperties) {
for (var key in type) {
if (typeof type[key] === 'function') {
if (onlyOwnProperties && !type.hasOwnProperty(key)) {
continue;
}
(function(methodName) {
var _method = type[methodName];