Skip to content

Instantly share code, notes, and snippets.

@derzunov
derzunov / disable_nsurlsessionid.sh
Created December 3, 2016 16:17 — forked from akhy/disable_nsurlsessionid.sh
Disable NSURLSessionId
launchctl unload /System/Library/LaunchDaemons/com.apple.nsurlstoraged.plist
launchctl unload /System/Library/LaunchAgents/com.apple.nsurlsessiond.plist
sudo launchctl unload /System/Library/LaunchDaemons/com.apple.nsurlsessiond.plist
sudo launchctl unload /System/Library/LaunchDaemons/com.apple.nsurlstoraged.plist
{
'key_name': ["С момента входа ", ["прошёл", "прошло", "прошло"], " ", "$count", " ", ["час", "часа", "часов"]],
// ...
}
// Full example code see here - https://github.com/derzunov/redux-react-i18n/tree/master/example
import { i18nActions, i18nReducer, Loc } from 'redux-react-i18n';
//...
// Code Code Code ...
//...
store.dispatch( i18nActions.setLanguages(
[
{
{
'key_simple': 'Дайте, пожалуйста, два билета в вагон второго класса в Варшаву.',
'key_with_plurals': [["Остался", "Осталось", "Осталось"], " ", "$count", " ", ["час", "часа", "часов"]],
'key_simple_with_number': 'Просто число после двоеточия: $Count'
}
{
'key_simple': 'Prosze, dwa bilety drugiej klasy do Warszawy.',
'key_with_plurals': [["Pozostała", "Pozostały", "Pozostało"], " ", "$count", " ", ["godzina", "godziny", "godzin"]],
'key_simple_with_number': 'Numer: $Count'
}
@derzunov
derzunov / medium__sails_pasport_fb__auth_controller.js
Created October 14, 2016 19:19
your_cool_project/api/controllers/AuthController.js
var passport = require( 'passport' );
module.exports = {
facebook: function( req, res, next ) {
return passport.authenticate('facebook', {
scope: ['email']
})( req, res, next );
},
@derzunov
derzunov / medium__sails_pasport_fb__http.js
Created October 14, 2016 19:09
your_cool_project/config/http.js
module.exports.http = {
middleware: {
passportInit : require('passport').initialize(),
passportSession : require('passport').session(),
order: [
'startRequestTimer',
'cookieParser',
'session',
@derzunov
derzunov / medium__sails_pasport_fb__user.js
Created October 14, 2016 19:01
your_cool_project/api/models/User.js
module.exports = {
attributes: {
name: {
type: 'string',
minLength: 42
}
/*
и другие атрибуты и attribute/instance методы...
*/
@derzunov
derzunov / medium__sails_pasport_fb_config_passport.js
Created October 14, 2016 18:38
your_cool_project/config/passport.js
var passport = require( 'passport' ),
FacebookStrategy = require( 'passport-facebook' ).Strategy;
passport.use( new FacebookStrategy({
clientID: YOUR_CLIENT_ID, // Получить тут - https://developers.facebook.com/
clientSecret: YOUR_CLIENT_SECRET, // Получить тут - https://developers.facebook.com/
callbackURL: "/auth/callback", // Наш урл коллбэка в контроллере AuthController
enableProof: false,
profileFields: ['id', 'email', 'name'] // Поля, которые мы хотим получить у пользователя facebook
},
@derzunov
derzunov / yuotube_id_from_url.coffee
Last active August 29, 2016 20:32
YouTube video id parser
link = "https://www.youtube.com/watch?v=Imeq3GeRttw"
link2 = "http://www.youtube.com/v/0zM3nApSvMg?fs=1&hl=en_US&rel=0"
link3 = "http://www.youtube.com/watch?v=EqS7oJcBi7w#t=0m10s"
youtube_parser = ( url ) ->
regExp = /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*/
match = url.match regExp
if match and match[7].length == 11 then match[7] else false
console.log youtube_parser( link ), youtube_parser( link2 ), youtube_parser( link3 )