Is there a way to block your friends from seeing who liked your photos on Facebook, but still see the number of likes? I mean "1000 people like X's photo" but not showing who.

I'm looking for a native OSX desktop application (needs to work offline) in which I can edit plain text documents, and preview how they'll look with markdown formatting applied.

At a minimum, I need it to be able to understand and display all the "official" markdown syntax, but save as straight-up .txt files.

I have a time authority and I want to securely set a client's time to this authority's time/date within a precision of $\delta$ seconds. The authority's public key is known to the client. This was my idea:

  1. A client sends a request with a 128-bit randomly generated nonce to the authority, and starts a timer.
  2. The server replies with $time\_data$ and $sign(time\_data || nonce)$. $time\_data$ is some representation of time with a high precision and constant length (for example 16 bytes).
  3. The client waits until a response is received or until $2\delta$ seconds have passed.
  4. The client stops the timer, having measured $\Delta t$ since it started, and verifies that ${\Delta t \over 2} < \delta$. Then it verifies the signature using the given time data and the latest sent nonce. If everything passes then it sets the time to $time\_data + {\Delta t \over 2}$. If not go back to step 1.

As far as I can see there is no attack on this scheme that allows any adversary to let the client accept a time that is not within $\delta$ seconds of the actual time of the authority. Am I missing something?

I'm also wondering if there's any way to improve precision above the minimum delay $\Delta t$ of the network without losing security of the synchronized time, similar to what NTP does with estimating network latency.

Some pools use a modified bitcoind that uses different rules for choosing the transactions to include in a block. Are there any pools that knowing one transaction to be included in a block would discard it if another transaction on the same inputs would arrive with a higher fee? That is to say, when faced with a double spend attack between a transaction that arrived earlier and a transaction that pays them more, the pool would choose the latter?

Fairly recently, Computer Go programs became able to compete with humans using Monte-Carlo Search trees:

A Monte Carlo (MC) go program plays random games and easily evaluates the terminal position (win or loss). A MC program searches for moves that have high win rates, calculated from playing out at least a few hundred random games.

(This is a very simplified description. In practice one want to explore interesting branches with higher priority, so the randomness has to be controlled in some way using collected results. To play go at a reasonable level several millions of random games still have to be played out. But, hopefully it's quite fast to play randomly…)

I feel like a lot more games could be “addressed” using this method, and that could include maybe a vast majority of board games…

Two questions:

  • Has the Monte Carlo method already been applied to other games? (Are there concrete implementations available?)

  • For which kind of games, among those that have clearly stated rules and won't rely on complex communication between players, this method can be expected to fail?

I wrote a small code in Python to conduct a backtest. My rebalance function is very slow and I would like to improve it. I need to profile it but I would welcome any opinion on how to refactor my code nicely.

def Rebalance(self, currentDate, data, VolatilityForSizing,Wthtslippage=True):
        # Handle open positions
        yesterday = max(self.PtfHandler.Positions.index[self.PtfHandler.Positions.index<currentDate])
        CurrentPositions = self.PtfHandler.Positions.loc[yesterday]
        OpenPositions = CurrentPositions[CurrentPositions !=0].keys()
        NotOpenPositions = set(CurrentPositions.keys())-set(OpenPositions)

        # Save Metrics in Ptf
        PositionPnL = dict.fromkeys(NotOpenPositions,0)
        PtfMetrics = dict()
        PtfMetrics['Date'] = currentDate
        PtfMetrics['TradedPositions'] = len(OpenPositions)
        SumReturn = 0

        # FirstSignal at current date from FirstSignalHandler
        FirstSignalSetMax = set(CurrentPositions[self.FirstSignalHandler.FirstSignalSetMax.loc[currentDate]].keys())
        FirstSignalSetMin = set(CurrentPositions[self.FirstSignalHandler.FirstSignalSetMin.loc[currentDate]].keys())

        goLongCandidate = self.SecondSignal.initiateLong.ix[currentDate]
        goShortCandidate = self.SecondSignal.initiateShort.ix[currentDate]

        goLongCandidate = goLongCandidate[goLongCandidate>0].keys() # turn goLongCandidate which is a serie into a list
        goShortCandidate = goShortCandidate[goShortCandidate>0].keys()

        PotentialLongToClose = set(CurrentPositions[CurrentPositions.isin(OpenPositions) & CurrentPositions>0].keys())
        LongToClose = list(PotentialLongToClose.intersection(FirstSignalSetMax))
        self.PtfHandler.Positions.loc[currentDate,LongToClose] = 0
        for stock in LongToClose:
            pnl = self.PtfHandler.getNonTradedPositionPnL(currentDate,yesterday,stock,CurrentPositions[stock],data,self.FirstSignalHandler.VolOnEntry)
            pnl = pnl + self.PtfHandler.getSlippageImpact(stock,CurrentPositions[stock],self.FirstSignalHandler.VolOnEntry,saveReturnWthSlippage=Wthtslippage)
            SumReturn = SumReturn + pnl

        PotentialShortToClose = set(CurrentPositions[CurrentPositions.isin(OpenPositions) & CurrentPositions<0].keys())
        ShortToClose = list(PotentialShortToClose.intersection(FirstSignalSetMin))
        self.PtfHandler.Positions.loc[currentDate,ShortToClose] = 0
        for stock in ShortToClose:
            pnl = self.PtfHandler.getNonTradedPositionPnL(currentDate,yesterday,stock,CurrentPositions[stock],data,self.FirstSignalHandler.VolOnEntry)
            pnl = pnl + self.PtfHandler.getSlippageImpact(stock,CurrentPositions[stock],self.FirstSignalHandler.VolOnEntry,saveReturnWthSlippage=Wthtslippage)
            SumReturn = SumReturn + pnl

        NewPotentialLong = set(goLongCandidate).intersection(NotOpenPositions)
        NewPotentialLong = list(NewPotentialLong.intersection(FirstSignalSetMax))
        for stock in NewPotentialLong:
            qty = self.AssetManager.getNewTradeWeight(currentDate, stock,VolatilityForSizing)
            self.PtfHandler.Positions.loc[currentDate,stock] =qty
            pnl = self.PtfHandler.getSlippageImpact(stock,qty,self.FirstSignalHandler.VolOnEntry,saveReturnWthSlippage=Wthtslippage)
            SumReturn = SumReturn + pnl

        NewPotentialShort = set(goShortCandidate).intersection(NotOpenPositions)
        NewPotentialShort = list(NewPotentialShort.intersection(FirstSignalSetMin))
        for stock in NewPotentialShort:
            qty = self.AssetManager.getNewTradeWeight(currentDate, stock,VolatilityForSizing)
            self.PtfHandler.Positions.loc[currentDate,stock] =-qty
            pnl = self.PtfHandler.getSlippageImpact(stock,qty,self.FirstSignalHandler.VolOnEntry,saveReturnWthSlippage=Wthtslippage)
            SumReturn = SumReturn + pnl
            PositionPnL[stock]= pnl

        # Save portfolio positions and returns given rebalancing
        NotTradedPositions = list(set(OpenPositions)-set(ShortToClose)-set(LongToClose))
        for stock in NotTradedPositions:
            pnl = self.PtfHandler.getNonTradedPositionPnL(currentDate,yesterday,stock,CurrentPositions[stock],data,self.FirstSignalHandler.VolOnEntry)
            SumReturn = SumReturn + pnl

        self.PtfHandler.AdjustedReturns = self.PtfHandler.AdjustedReturns.append(PositionPnL,ignore_index=True)
        PtfMetrics['PtfAdjReturn'] = SumReturn
        YesterdayCumReturn = self.PtfHandler.PtfAdjustedReturns.ix[-1]['CumReturn'] if not self.PtfHandler.PtfAdjustedReturns.empty else 0
        PtfMetrics['CumReturn'] = YesterdayCumReturn + SumReturn
        self.PtfHandler.PtfAdjustedReturns = self.PtfHandler.PtfAdjustedReturns.append(PtfMetrics,ignore_index=True)

Edit: I just profiled the function. The first calculation to get yesterday date is very costly - which I thought. DataFrame.append is also very costly. Same for the PnL calculation. I probably need to improve the function.


Выведите IP адрес под которым машина отправляет запросы к (учитывать NAT после выхода пакета из машины не нужно, нужен IP адрес с которым пакет покидает машину).

Нужно написать Bash-скрипт. Как я понимаю, нужно понять где у нас в локальной сети шлюз.

На данный момент готово следующее:

используем tcpdump - tcpdump -i any 'udp port 53' > whoIP - таким образом результат дампа со всеми запросами на 53 порт(т.е. DNS) сохраняется в файл.

Файл содержит следующие строки:

15:09:44.365818 IP > 31675+ A? (42)

15:09:44.398267 IP > 31675 7/0/0 CNAME, A

затем при помощи "Адского" выражения: cat whoIP | grep A? | grep -E -o '>+ ([0-9]{1,3}[.]){3}[0-9]{1,3}'| grep -E -o "([0-9]{1,3}[.]){3}[0-9]{1,3}"

Логика его такова:

  1. cat whoIP |grep A? - в файле мы ищем строки содержащие запрос на разрешении имени. tcpdump помечает такие строки A?

  2. | grep -E -o '>+ ([0-9]{1,3}[.]){3}[0-9]{1,3}' - данное регулярное выражение ищет IP-адрес в формате ipv4. в строке мы ищем следующую конструкцию "> "ipv4 адрес"" - в tcpdump ">" означает от кого к кому идет запрос. Нас интересует к кому.

  3. | grep -E -o "([0-9]{1,3}[.]){3}[0-9]{1,3}" - из найденного фрагмента "к кому" вырезаем только адрес.Данное выражение от предыдущего отличается лишь отсутствием "<"

    В целом мой алгоритм следующий:

1.Запустить tcpdump и перенаправить его вывод в файл whoIP

  1. Послать в другом терминал DNS-запрос при помощи dig


  3. grep файл

Во-первых, проблема в том, что в скрипт данную последовательность я заложить не могу, т.к. tcpdump работает пока ему не послать сигнал завершения( вот тут и загвоздка). Если в скрипте ищет запуск tcpdump, то следующие команды не исполняются, т.к. tcpdump работает бесконечно.

Подскажите, можно ли написать данный скрипт и вообще иду ли я по верному пути, в чем сомневаюсь очень сильно. Мне кажется, должно быть более простое решение.

I upgraded an 11.10 box to 12.04 yesterday. This morning I tried to run an apt-get upgrade and encountered the following:

sudo apt-get upgrade
[sudo] password for brian: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages have been kept back:
  linux-generic linux-headers-generic linux-image-generic
The following packages will be upgraded:
  apport apport-gtk firefox firefox-globalmenu firefox-gnome-support firefox-locale-en linux-libc-dev python-apport python-problem-report unity-scope-musicstores
10 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
Need to get 20.1 MB of archives.
After this operation, 594 kB of additional disk space will be used.
Do you want to continue [Y/n]? 
WARNING: The following packages cannot be authenticated!
  python-problem-report python-apport apport apport-gtk linux-libc-dev unity-scope-musicstores

Any help is greatly appreciated. Thanks!

Genesis 19:15–26 (ESV)

15 As morning dawned, the angels urged Lot, saying, “Up! Take your wife and your two daughters who are here, lest you be swept away in the punishment of the city.” 16 But he lingered. So the men seized him and his wife and his two daughters by the hand, the Lord being merciful to him, and they brought him out and set him outside the city. 17 And as they brought them out, one said, “Escape for your life. Do not look back or stop anywhere in the valley. Escape to the hills, lest you be swept away.” 18 And Lot said to them, “Oh, no, my lords. 19 Behold, your servant has found favor in your sight, and you have shown me great kindness in saving my life. But I cannot escape to the hills, lest the disaster overtake me and I die. 20 Behold, this city is near enough to flee to, and it is a little one. Let me escape there—is it not a little one?—and my life will be saved!” 21 He said to him, “Behold, I grant you this favor also, that I will not overthrow the city of which you have spoken. 22 Escape there quickly, for I can do nothing till you arrive there.” Therefore the name of the city was called Zoar.

God Destroys Sodom

23 The sun had risen on the earth when Lot came to Zoar. 24 Then the Lord rained on Sodom and Gomorrah sulfur and fire from the Lord out of heaven. 25 And he overthrew those cities, and all the valley, and all the inhabitants of the cities, and what grew on the ground. 26 But Lot's wife, behind him, looked back, and she became a pillar of salt.

The text doesn't answer or indicate why Lot's wife looked back, and Googling the question doesn't really turn up very much that's useful. Is there anything in the doctrines of Protestant denominations (the closer to Wesleyan, the better) that explains why Lot's wife looked back?

The Python 3.1.5 docs refer to the % style formatting as "Old String Formatting Operations" and provide this warning that it may be removed:

Note: The formatting operations described here are obsolete and may go away in future versions of Python. Use the new String Formatting in new code.

The replacement section appears to be printf-style String Formatting . It contains this warning:

Note: The formatting operations described here exhibit a variety of quirks that lead to a number of common errors (such as failing to display tuples and dictionaries correctly). Using the newer str.format() interface helps avoid these errors, and also provides a generally more powerful, flexible and extensible approach to formatting text.

So it is still clearly discouraged, but why was the note about possibly removing the feature cut from the docs? Was this some sort of policy decision or enforcement, since it's not officially deprecated yet? Are there still plans to eventually deprecate and remove it?