Skip to content

Instantly share code, notes, and snippets.

View dmitrizzle's full-sized avatar
📸
🎞

dmitrizzle

📸
🎞
View GitHub Profile
@blotus
blotus / log4j_exploitation_attempts_crowdsec.md
Last active December 29, 2023 12:24
IPs exploiting the log4j2 CVE-2021-44228 detected by the crowdsec community

This list is no longer updated, thus the information is no longer reliable.

You can see the latest version (from october 2022) here

@DavidKuennen
DavidKuennen / minimal-analytics-snippet.js
Last active May 3, 2024 12:55
Minimal Analytics Snippet
(function (context, trackingId, options) {
const history = context.history;
const doc = document;
const nav = navigator || {};
const storage = localStorage;
const encode = encodeURIComponent;
const pushState = history.pushState;
const typeException = 'exception';
const generateId = () => Math.random().toString(36);
const getId = () => {
@wmertens
wmertens / slateToReact.js
Created July 6, 2018 05:17
Convert Slate JSON object to React element tree
@@ -0,0 +1,62 @@
import React from 'react'
import RULES from './somewhere' // What you normally feed slate-html-serializer
const rules = [
...RULES,
// from slate-html-serializer
{
serialize(obj, children) {
if (obj.object === 'string') {
@zGrav
zGrav / paste.js
Last active January 7, 2018 06:13
import Html from 'slate-html-serializer';
// import React from 'react';
// import { FunctionTypes } from 'constants/editor/ViewModel';
// import { Nodes } from 'components/editor';
import { getEventTransfer } from 'slate-react';
import { BlockTypes } from 'constants/editor';
import { Block } from 'slate';
@cereallarceny
cereallarceny / index.js
Created October 12, 2017 20:37
Server-side rendering with create-react-app (Fiber), React Router v4, Helmet, Redux, and Thunk
// Ignore those pesky styles
require('ignore-styles');
// Set up babel to do its thing... env for the latest toys, react-app for CRA
require('babel-register')({
ignore: /\/(build|node_modules)\//,
presets: ['env', 'react-app']
});
// Now that the nonsense is over... load up the server entry point
const wrapperStyle = {
position: 'relative'
}
const PlaceHolder = React.createClass({
renderPlaceholder(){
const { node, state } = this.props;
const placeholderText = node.data.get('placeholderText');
return (
@Dagnan
Dagnan / application.html.erb
Last active November 21, 2020 19:10 — forked from averyvery/application.rb
Inline CSS or JS in Rails 5
<!DOCTYPE html>
<html>
<head>
<%= inline_js 'application.js' %>
<%= inline_css 'application.css' %>
</head>
<body>
</body>
</html>
import React from 'react';
import { renderToStaticMarkup } from 'react-dom/server';
class SvgBackground extends React.Component {
render() {
return (
<svg xmlns='http://www.w3.org/2000/svg' width={100} height={100}>
<rect width={100} height={100} fill='#269' />
<g fill='#6494b7'>
<rect width={100} height={1} y={20} />
@markbao
markbao / # Integrating Slate into a Rails app.md
Created July 15, 2016 22:33
Integrating Slate into a Rails app

Integrating Slate into a Rails app

Want to use the excellent rich text editor Slate in a Rails app? Beware – since you'll be integrating React with your Rails app, it'll turn out pretty complicated and you'll have to do things (e.g. start server, managing dependencies, etc.) a bit differently than before. Let's start.

1. Install react_on_rails

react_on_rails is pretty much the best option for integrating React into Rails. Install it like so:

  1. Add this to your gemfile:
/**
* Michael Scott Hertzberg <mshertzberg@gmail.com> (http://hertzber.gs)
*
* recursively check for set localStorage value every 100ms.
* this will also safely clear the timeout once found.
* can be used callback style or directly.
* functionally pure.
*/
function waitForLocalStorage(key, cb, timer) {
if (!localStorage.getItem(key)) return (timer = setTimeout(waitForLocalStorage.bind(null, key, cb), 100))