text:
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

var _bluebird = _interopRequireDefault(require("bluebird"));

var _events = require("events");

var _debug = _interopRequireDefault(require("debug"));

var _makeKnex = _interopRequireDefault(require("./util/make-knex"));

var _lodash = require("lodash");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

// Transaction
// -------
const debug = (0, _debug.default)('knex:tx');

// Acts as a facade for a Promise, keeping the internal state
// and managing any child transactions.
class Transaction extends _events.EventEmitter {
  constructor(client, container, config, outerTx) {
    super();
    const txid = this.txid = (0, _lodash.uniqueId)('trx');
    this.client = client;
    this.logger = client.logger;
    this.outerTx = outerTx;
    this.trxClient = undefined;
    this._debug = client.config && client.config.debug;
    debug('%s: Starting %s transaction', txid, outerTx ? 'nested' : 'top level');
    this._promise = _bluebird.default.using(this.acquireConnection(client, config, txid), connection => {
      const trxClient = this.trxClient = makeTxClient(this, client, connection);
      const init = client.transacting ? this.savepoint(connection) : this.begin(connection);
      init.then(() => {
        return makeTransactor(this, connection, trxClient);
      }).then(transactor => {
        // If we've returned a "thenable" from the transaction container, assume
        // the rollback and commit are chained to this object's success / failure.
        // Directly thrown errors are treated as automatic rollbacks.
        let result;

        try {
          result = container(transactor);
        } catch (err) {
          result = _bluebird.default.reject(err);
        }

        if (result && result.then && typeof result.then === 'function') {
          result.then(val => {
            return transactor.commit(val);
          }).catch(err => {
            return transactor.rollback(err);
          });
        }

        return null;
      }).catch(e => this._rejecter(e));
      return new _bluebird.default((resolver, rejecter) => {
        this._resolver = resolver;
        this._rejecter = rejecter;
      });
    });
    this._completed = false; // If there's a wrapping transaction, we need to wait for any older sibling
    // transactions to settle (commit or rollback) before we can start, and we
    // need to register ourselves with the parent transaction so any younger
    // siblings can wait for us to complete before they can start.

    this._previousSibling = _bluebird.default.resolve(true);

    if (outerTx) {
      if (outerTx._lastChild) this._previousSibling = outerTx._lastChild;
      outerTx._lastChild = this._promise;
    }
  }

  isCompleted() {
    return this._completed || this.outerTx && this.outerTx.isCompleted() || false;
  }

  begin(conn) {
    return this.query(conn, 'BEGIN;');
  }

  savepoint(conn) {
    return this.query(conn, `SAVEPOINT ${this.txid};`);
  }

  commit(conn, value) {
    return this.query(conn, 'COMMIT;', 1, value);
  }

  release(conn, value) {
    return this.query(conn, `RELEASE SAVEPOINT ${this.txid};`, 1, value);
  }

  rollback(conn, error) {
    return this.query(conn, 'ROLLBACK', 2, error).timeout(5000).catch(_bluebird.default.TimeoutError, () => {
      this._rejecter(error);
    });
  }

  rollbackTo(conn, error) {
    return this.query(conn, `ROLLBACK TO SAVEPOINT ${this.txid}`, 2, error).timeout(5000).catch(_bluebird.default.TimeoutError, () => {
      this._rejecter(error);
    });
  }

  query(conn, sql, status, value) {
    const q = this.trxClient.query(conn, sql).catch(err => {
      status = 2;
      value = err;
      this._completed = true;
      debug('%s error running transaction query', this.txid);
    }).tap(() => {
      if (status === 1) {
        this._resolver(value);
      }

      if (status === 2) {
        if ((0, _lodash.isUndefined)(value)) {
          value = new Error(`Transaction rejected with non-error: ${value}`);
        }

        this._rejecter(value);
      }
    });

    if (status === 1 || status === 2) {
      this._completed = true;
    }

    return q;
  }

  debug(enabled) {
    this._debug = arguments.length ? enabled : true;
    return this;
  } // Acquire a connection and create a disposer - either using the one passed
  // via config or getting one off the client. The disposer will be called once
  // the original promise is marked completed.

  acquireConnection(client, config, txid) {
    const configConnection = config && config.connection;
    return _bluebird.default.try(() => configConnection || client.acquireConnection()).then(function (connection) {
      connection.__knexTxId = txid;
      return connection;
    }).disposer(function (connection) {
      if (!configConnection) {
        debug('%s: releasing connection', txid);
        client.releaseConnection(connection);
      } else {
        debug('%s: not releasing external connection', txid);
      }
    });
  }

} // The transactor is a full featured knex object, with a "commit", a "rollback"
// and a "savepoint" function. The "savepoint" is just sugar for creating a new
// transaction. If the rollback is run inside a savepoint, it rolls back to the
// last savepoint - otherwise it rolls back the transaction.

exports.default = Transaction;

function makeTransactor(trx, connection, trxClient) {
  const transactor = (0, _makeKnex.default)(trxClient);

  transactor.withUserParams = () => {
    throw new Error('Cannot set user params on a transaction - it can only inherit params from main knex instance');
  };

  transactor.isTransaction = true;
  transactor.userParams = trx.userParams || {};

  transactor.transaction = function (container, options) {
    return trxClient.transaction(container, options, trx);
  };

  transactor.savepoint = function (container, options) {
    return transactor.transaction(container, options);
  };

  if (trx.client.transacting) {
    transactor.commit = value => trx.release(connection, value);

    transactor.rollback = error => trx.rollbackTo(connection, error);
  } else {
    transactor.commit = value => trx.commit(connection, value);

    transactor.rollback = error => trx.rollback(connection, error);
  }

  return transactor;
} // We need to make a client object which always acquires the same
// connection and does not release back into the pool.

function makeTxClient(trx, client, connection) {
  const trxClient = Object.create(client.constructor.prototype);
  trxClient.version = client.version;
  trxClient.config = client.config;
  trxClient.driver = client.driver;
  trxClient.connectionSettings = client.connectionSettings;
  trxClient.transacting = true;
  trxClient.valueForUndefined = client.valueForUndefined;
  trxClient.logger = client.logger;
  trxClient.on('query', function (arg) {
    trx.emit('query', arg);
    client.emit('query', arg);
  });
  trxClient.on('query-error', function (err, obj) {
    trx.emit('query-error', err, obj);
    client.emit('query-error', err, obj);
  });
  trxClient.on('query-response', function (response, obj, builder) {
    trx.emit('query-response', response, obj, builder);
    client.emit('query-response', response, obj, builder);
  });
  const _query = trxClient.query;

  trxClient.query = function (conn, obj) {
    const completed = trx.isCompleted();
    return _bluebird.default.try(function () {
      if (conn !== connection) throw new Error('Invalid connection for transaction query.');
      if (completed) completedError(trx, obj);
      return _query.call(trxClient, conn, obj);
    });
  };

  const _stream = trxClient.stream;

  trxClient.stream = function (conn, obj, stream, options) {
    const completed = trx.isCompleted();
    return _bluebird.default.try(function () {
      if (conn !== connection) throw new Error('Invalid connection for transaction query.');
      if (completed) completedError(trx, obj);
      return _stream.call(trxClient, conn, obj, stream, options);
    });
  };

  trxClient.acquireConnection = function () {
    return _bluebird.default.resolve(connection);
  };

  trxClient.releaseConnection = function () {
    return _bluebird.default.resolve();
  };

  return trxClient;
}

function completedError(trx, obj) {
  const sql = typeof obj === 'string' ? obj : obj && obj.sql;
  debug('%s: Transaction completed: %s', trx.txid, sql);
  throw new Error('Transaction query already complete, run with DEBUG=knex:tx for more info');
}

const promiseInterface = ['then', 'bind', 'catch', 'finally', 'asCallback', 'spread', 'map', 'reduce', 'tap', 'thenReturn', 'return', 'yield', 'ensure', 'exec', 'reflect', 'get', 'mapSeries', 'delay']; // Creates methods which proxy promise interface methods to
// internal transaction resolution promise

promiseInterface.forEach(function (method) {
  Transaction.prototype[method] = function () {
    return this._promise[method].apply(this._promise, arguments);
  };
});
module.exports = exports.default;


text:
from neutron.openstack.common import log
from neutron.plugins.nicira.dbexts import nicira_db
from neutron.plugins.nicira import nvplib

LOG = log.getLogger(__name__)

def get_nsx_switch_and_port_id(session, cluster, neutron_port_id):
    """Return the NSX switch and port uuids for a given neutron port.

    First, look up the Neutron database. If not found, execute
    a query on NSX platform as the mapping might be missing because
    the port was created before upgrading to grizzly.

    This routine also retrieves the identifier of the logical switch in
    the backend where the port is plugged. Prior to Icehouse this
    information was not available in the Neutron Database. For dealing
    with pre-existing records, this routine will query the backend
    for retrieving the correct switch identifier.

    As of Icehouse release it is not indeed anymore possible to assume
    the backend logical switch identifier is equal to the neutron
    network identifier.
    """
    nvp_switch_id, nvp_port_id = nicira_db.get_nsx_switch_and_port_id(
        session, neutron_port_id)
    if not nvp_switch_id:
        # Find logical switch for port from backend
        # This is a rather expensive query, but it won't be executed
        # more than once for each port in Neutron's lifetime
        nvp_ports = nvplib.query_lswitch_lports(
            cluster, '*', relations='LogicalSwitchConfig',
            filters={'tag': neutron_port_id,
                     'tag_scope': 'q_port_id'})
        # Only one result expected
        # NOTE(salv-orlando): Not handling the case where more than one
        # port is found with the same neutron port tag
        if not nvp_ports:
            LOG.warn(_("Unable to find NVP port for Neutron port %s"),
                     neutron_port_id)
            # This method is supposed to return a tuple
            return None, None
        nvp_port = nvp_ports[0]
        nvp_switch_id = (nvp_port['_relations']
                         ['LogicalSwitchConfig']['uuid'])
        with session.begin(subtransactions=True):
            if nvp_port_id:
                # Mapping already exists. Delete before recreating
                nicira_db.delete_neutron_nsx_port_mapping(
                    session, neutron_port_id)
            else:
                nvp_port_id = nvp_port['uuid']
            # (re)Create DB mapping
            nicira_db.add_neutron_nsx_port_mapping(
                session, neutron_port_id,
                nvp_switch_id, nvp_port_id)
    return nvp_switch_id, nvp_port_id

redpajama_set_name: RedPajamaGithub


text:
package org.lyon_yan.app.android.lib_lyon_yan_utils;

import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.util.Enumeration;

import org.apache.http.conn.util.InetAddressUtils;

import android.app.Activity;
import android.content.Context;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.util.Log;

public class UtilsNet {
	public static String getLocalIpV6Address() {
		try {
			for (Enumeration<NetworkInterface> en = NetworkInterface
					.getNetworkInterfaces(); en.hasMoreElements();) {
				NetworkInterface intf = en.nextElement();
				for (Enumeration<InetAddress> enumIpAddr = intf
						.getInetAddresses(); enumIpAddr.hasMoreElements();) {
					InetAddress inetAddress = enumIpAddr.nextElement();
					if (!inetAddress.isLoopbackAddress()) {
						return inetAddress.getHostAddress().toString();
					}
				}
			}
		} catch (SocketException ex) {
			Log.e("lyon_1", ex.toString());
		}
		return null;
	}

	public static String getLocalIpV4Address() {

		try {
			for (Enumeration<NetworkInterface> en = NetworkInterface
					.getNetworkInterfaces(); en.hasMoreElements();) {
				NetworkInterface intf = en.nextElement();
				for (Enumeration<InetAddress> enumIpAddr = intf
						.getInetAddresses(); enumIpAddr.hasMoreElements();) {
					InetAddress inetAddress = enumIpAddr.nextElement();
					if (!inetAddress.isLoopbackAddress()
							&& InetAddressUtils.isIPv4Address(inetAddress
									.getHostAddress())) {
						return inetAddress.getHostAddress().toString();
					}
				}
			}
		} catch (SocketException e) {
			// TODO: handle exception
			Log.e("lyon_1", e.toString());
		}

		return null;
	}

	// // 得到本机ip地址
	// public static String getLocalHostIp() {
	// String ipaddress = "";
	// try {
	// Enumeration<NetworkInterface> en = NetworkInterface
	// .getNetworkInterfaces();
	// // 遍历所用的网络接口
	// while (en.hasMoreElements()) {
	// NetworkInterface nif = en.nextElement();// 得到每一个网络接口绑定的所有ip
	// Enumeration<InetAddress> inet = nif.getInetAddresses();
	// // 遍历每一个接口绑定的所有ip
	// while (inet.hasMoreElements()) {
	// InetAddress ip = inet.nextElement();
	// if (!ip.isLoopbackAddress()
	// && InetAddressUtils.isIPv4Address(ip
	// .getHostAddress())) {
	// return ipaddress = "本机的ip是" + ":" + ip.getHostAddress();
	// }
	// }
	//
	// }
	// } catch (SocketException e) {
	// Log.e("feige", "获取本地ip地址失败");
	// e.printStackTrace();
	// }
	// return ipaddress;
	//
	// }

	// 得到本机Mac地址
	public static String getLocalMac(Activity activity) {
		String mac = "";
		// 获取wifi管理器
		WifiManager wifiMng = (WifiManager) activity
				.getSystemService(Context.WIFI_SERVICE);
		WifiInfo wifiInfor = wifiMng.getConnectionInfo();
		mac = "本机的mac地址是:" + wifiInfor.getMacAddress();
		return mac;
	}
}


text:
<!-- The main content view -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              xmlns:app="http://schemas.android.com/apk/res-auto"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:layout_below="@id/myToolbar"
              android:orientation="vertical">

    <View
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"/>

    <com.beardedhen.androidbootstrap.BootstrapButton
        android:id="@+id/btnCurrent"
        android:layout_width="@dimen/main_button_width"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:layout_marginBottom="24dp"
        app:bootstrapBrand="success"
        app:bootstrapSize="lg"
        app:bootstrapText="@string/button_current_trip"
        app:buttonMode="regular"
        app:roundedCorners="true"
        app:showOutline="false"/>

    <com.beardedhen.androidbootstrap.BootstrapButton
        android:id="@+id/btnNewTrip"
        android:layout_width="@dimen/main_button_width"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:layout_marginBottom="24dp"
        app:bootstrapBrand="success"
        app:bootstrapSize="lg"
        app:bootstrapText="@string/button_new_trip"
        app:buttonMode="regular"
        app:roundedCorners="true"
        app:showOutline="false"/>

    <com.beardedhen.androidbootstrap.BootstrapButton
        android:id="@+id/btnAllTrip"
        android:layout_width="@dimen/main_button_width"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:layout_marginBottom="24dp"
        app:bootstrapBrand="success"
        app:bootstrapSize="lg"
        app:bootstrapText="@string/button_all_trip"
        app:buttonMode="regular"
        app:roundedCorners="true"
        app:showOutline="false"/>

    <com.beardedhen.androidbootstrap.BootstrapButton
        android:id="@+id/btnImportTrip"
        android:layout_width="@dimen/main_button_width"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:layout_marginBottom="24dp"
        app:bootstrapBrand="success"
        app:bootstrapSize="lg"
        app:bootstrapText="@string/button_import_trip"
        app:buttonMode="regular"
        app:roundedCorners="true"
        app:showOutline="false"/>

    <View
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"/>
</LinearLayout>


text:
package org.objectweb.asm.optimizer;

import org.objectweb.asm.AnnotationVisitor;
import org.objectweb.asm.Attribute;
import org.objectweb.asm.FieldVisitor;
import org.objectweb.asm.Label;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.Type;
import org.objectweb.asm.commons.Remapper;
import org.objectweb.asm.commons.RemappingMethodAdapter;

/**
 * A {@link MethodVisitor} that renames fields and methods, and removes debug
 * info.
 *
 * @author Eugene Kuleshov
 */
public class MethodOptimizer extends RemappingMethodAdapter implements Opcodes {

    private final ClassOptimizer classOptimizer;

    public MethodOptimizer(ClassOptimizer classOptimizer, int access,
            String desc, MethodVisitor mv, Remapper remapper) {
        super(access, desc, mv, remapper);
        this.classOptimizer = classOptimizer;
    }

    // ------------------------------------------------------------------------
    // Overridden methods
    // ------------------------------------------------------------------------

    @Override
    public AnnotationVisitor visitAnnotationDefault() {
        // remove annotations
        return null;
    }

    @Override
    public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
        // remove annotations
        return null;
    }

    @Override
    public AnnotationVisitor visitParameterAnnotation(final int parameter,
            final String desc, final boolean visible) {
        // remove annotations
        return null;
    }

    @Override
    public void visitLocalVariable(final String name, final String desc,
            final String signature, final Label start, final Label end,
            final int index) {
        // remove debug info
    }

    @Override
    public void visitLineNumber(final int line, final Label start) {
        // remove debug info
    }

    @Override
    public void visitFrame(int type, int local, Object[] local2, int stack,
            Object[] stack2) {
        // remove frame info
    }

    @Override
    public void visitAttribute(Attribute attr) {
        // remove non standard attributes
    }

    @Override
    public void visitLdcInsn(Object cst) {
        if (!(cst instanceof Type)) {
            super.visitLdcInsn(cst);
            return;
        }

        // transform Foo.class to foo$(class) for 1.2 compatibility
        String ldcName = ((Type) cst).getInternalName();
        String fieldName = "class$" + ldcName.replace('/', '$');

        FieldVisitor fv = classOptimizer.syntheticFieldVisitor(ACC_STATIC
                | ACC_SYNTHETIC, fieldName, "Ljava/lang/Class;");
        fv.visitEnd();

        if (!classOptimizer.class$) {
            MethodVisitor mv = classOptimizer.visitMethod(ACC_STATIC
                    | ACC_SYNTHETIC, "class$",
                    "(Ljava/lang/String;)Ljava/lang/Class;", null, null);
            mv.visitCode();
            Label l0 = new Label();
            Label l1 = new Label();
            Label l2 = new Label();
            mv.visitTryCatchBlock(l0, l1, l2,
                    "java/lang/ClassNotFoundException");
            mv.visitLabel(l0);
            mv.visitVarInsn(ALOAD, 0);
            mv.visitMethodInsn(INVOKESTATIC, "java/lang/Class", "forName",
                    "(Ljava/lang/String;)Ljava/lang/Class;");
            mv.visitLabel(l1);
            mv.visitInsn(ARETURN);
            mv.visitLabel(l2);
            mv.visitMethodInsn(INVOKEVIRTUAL,
                    "java/lang/ClassNotFoundException", "getMessage",
                    "()Ljava/lang/String;");
            mv.visitVarInsn(ASTORE, 1);
            mv.visitTypeInsn(NEW, "java/lang/NoClassDefFoundError");
            mv.visitInsn(DUP);
            mv.visitVarInsn(ALOAD, 1);
            mv.visitMethodInsn(INVOKESPECIAL, "java/lang/NoClassDefFoundError",
                    "<init>", "(Ljava/lang/String;)V");
            mv.visitInsn(ATHROW);
            mv.visitMaxs(3, 2);
            mv.visitEnd();

            classOptimizer.class$ = true;
        }

        String clsName = classOptimizer.clsName;
        mv.visitFieldInsn(GETSTATIC, clsName, fieldName, "Ljava/lang/Class;");
        Label elseLabel = new Label();
        mv.visitJumpInsn(IFNONNULL, elseLabel);
        mv.visitLdcInsn(ldcName.replace('/', '.'));
        mv.visitMethodInsn(INVOKESTATIC, clsName, "class$",
                "(Ljava/lang/String;)Ljava/lang/Class;");
        mv.visitInsn(DUP);
        mv.visitFieldInsn(PUTSTATIC, clsName, fieldName, "Ljava/lang/Class;");
        Label endLabel = new Label();
        mv.visitJumpInsn(GOTO, endLabel);
        mv.visitLabel(elseLabel);
        mv.visitFieldInsn(GETSTATIC, clsName, fieldName, "Ljava/lang/Class;");
        mv.visitLabel(endLabel);
    }
}


text:
{-# OPTIONS_GHC -Wincomplete-patterns -Wno-missing-methods -fforce-recomp #-}
{-# LANGUAGE GADTs, TypeFamilies, ViewPatterns, TypeOperators, PatternSynonyms #-}
module Lib where

import Data.Type.Equality

data family T a

data instance T () = A

pattern B :: a
pattern B <- (const False -> True)

pattern C :: a
pattern C <- (const True -> True)

{-# COMPLETE B, C :: T #-}

f :: a :~: () -> T a -> ()
f _    B = ()
f Refl A = ()


text:
var width = $(window).width();
var height = $(window).height();

// dynamic header size
$(function dynamicHeader() {
  var isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent) ? true : false;

  if(!isMobile && height > 750) {
    $('header').css({'height': height + 2 + "px"});
  }
});

// Navbar background opacity
$(function navOpacity() {
  var nav = $(".navbar-main");

  $(window).scroll(function() {
    if ($(this).scrollTop() > (height - 66)) {
      nav.css({'background-color': '#fff','color': '#000'});
      nav.find('a').css({'color': '#000'});
    } else{
      nav.css({'background': 'transparent','color': '#fff'});
      nav.find('a').css({'color': '#fff'});
    }
  });
});

// jQuery for page scrolling feature - requires jQuery Easing plugin
$(function pageScroll() {
  var nav        = $('.navbar-main');
  var nav_height = nav.outerHeight();

  $('body').on('click', 'nav a', function(event) {
    var $anchor = $(this);
    event.preventDefault();

    $('html, body').stop().animate({
      scrollTop: $($anchor.attr('href')).offset().top - (nav_height + 10) });

    if(width < 769) {
      $(".navbar-mobile ul.expanded").removeClass("expanded").slideUp('fast');
      $(this).removeClass("open");
    }
  });
});


text:
发布

<input type="text" name="title" id="title" placeholder="标题">

<input type="text" class="write-tag" placeholder="文章标签,按 enter 插入">

 + 插入头图<input type="file" id="file" class="media-file">

 + 插入音乐

			X

			<textarea name="content" id="content" placeholder="从这里开始"></textarea>

			<input type="text" name="captcha" id="captcha" placeholder="验证码">

		{% if followers %}

			<input type="text" name="assign" id="assign" placeholder="指定给 ta 看">

				{% for artist in followers %}

						{{artist.nickname}}

				{% endfor %}

		{% endif %}

			<input type="checkbox" name="private" id="private">仅自己可见

			<input type="checkbox" name=" public" id="public">所有人都可以见(包括未登录用户)

<button class="postBtn btn btn-primary">发布</button>

{% macro pop(id) -%}
<template id="{{id}}">

			{{caller()}}

</template>
{%- endmacro %}
{% call pop('popA') %}
    发布成功
{% endcall %}
{% call pop('popB') %}
    秋刀马爹,发布中...
{% endcall %}
{% call pop('popC') %}
    标题或者内容不能为空
{% endcall %}
<template id="insertMusic">

插入音乐...

			<textarea class="insertMusic-value" placeholder="外链音乐HTML代码"></textarea>

			插入

</template>